[FIX] website_sale_aplicoop: Remove redundant string= attributes and fix OCA linting warnings

- Remove redundant string= from 17 field definitions where name matches string value (W8113)
- Convert @staticmethod to instance methods in selection methods for proper self.env._() access
- Fix W8161 (prefer-env-translation) by using self.env._() instead of standalone _()
- Fix W8301/W8115 (translation-not-lazy) by proper placement of % interpolation outside self.env._()
- Remove unused imports of odoo._ from group_order.py and sale_order_extension.py
- All OCA linting warnings in website_sale_aplicoop main models are now resolved

Changes:
- website_sale_aplicoop/models/group_order.py: 21 field definitions cleaned
- website_sale_aplicoop/models/sale_order_extension.py: 5 field definitions cleaned + @staticmethod conversion
- Consistent with OCA standards for addon submission
This commit is contained in:
snt 2026-02-18 17:54:43 +01:00
parent 5c89795e30
commit 6fbc7b9456
73 changed files with 5386 additions and 4354 deletions

View file

@ -1,4 +1,6 @@
from odoo import models, fields, api
from odoo import api
from odoo import fields
from odoo import models
class ResConfigSettings(models.TransientModel):

View file

@ -10,25 +10,31 @@ class TestResConfigSettings(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.pricelist = cls.env["product.pricelist"].create({
"name": "Test Config Pricelist",
"currency_id": cls.env.company.currency_id.id,
})
cls.pricelist = cls.env["product.pricelist"].create(
{
"name": "Test Config Pricelist",
"currency_id": cls.env.company.currency_id.id,
}
)
def test_config_parameter_set_and_get(self):
"""Test setting and getting pricelist configuration"""
config = self.env["res.config.settings"].create({
"product_pricelist_automatic": self.pricelist.id,
})
config.execute()
# Verify parameter was saved
saved_id = self.env["ir.config_parameter"].sudo().get_param(
"product_sale_price_from_pricelist.product_pricelist_automatic"
config = self.env["res.config.settings"].create(
{
"product_pricelist_automatic": self.pricelist.id,
}
)
config.execute()
# Verify parameter was saved
saved_id = (
self.env["ir.config_parameter"]
.sudo()
.get_param("product_sale_price_from_pricelist.product_pricelist_automatic")
)
self.assertEqual(int(saved_id), self.pricelist.id)
def test_config_load_from_parameter(self):
@ -36,43 +42,51 @@ class TestResConfigSettings(TransactionCase):
# Set parameter directly
self.env["ir.config_parameter"].sudo().set_param(
"product_sale_price_from_pricelist.product_pricelist_automatic",
str(self.pricelist.id)
str(self.pricelist.id),
)
# Create config and check if value is loaded
config = self.env["res.config.settings"].create({})
self.assertEqual(config.product_pricelist_automatic.id, self.pricelist.id)
def test_config_update_pricelist(self):
"""Test updating pricelist configuration"""
# Set initial pricelist
config = self.env["res.config.settings"].create({
"product_pricelist_automatic": self.pricelist.id,
})
config.execute()
# Create new pricelist and update
new_pricelist = self.env["product.pricelist"].create({
"name": "New Config Pricelist",
"currency_id": self.env.company.currency_id.id,
})
config2 = self.env["res.config.settings"].create({
"product_pricelist_automatic": new_pricelist.id,
})
config2.execute()
# Verify new value
saved_id = self.env["ir.config_parameter"].sudo().get_param(
"product_sale_price_from_pricelist.product_pricelist_automatic"
config = self.env["res.config.settings"].create(
{
"product_pricelist_automatic": self.pricelist.id,
}
)
config.execute()
# Create new pricelist and update
new_pricelist = self.env["product.pricelist"].create(
{
"name": "New Config Pricelist",
"currency_id": self.env.company.currency_id.id,
}
)
config2 = self.env["res.config.settings"].create(
{
"product_pricelist_automatic": new_pricelist.id,
}
)
config2.execute()
# Verify new value
saved_id = (
self.env["ir.config_parameter"]
.sudo()
.get_param("product_sale_price_from_pricelist.product_pricelist_automatic")
)
self.assertEqual(int(saved_id), new_pricelist.id)
def test_config_without_pricelist(self):
"""Test configuration can be saved without pricelist"""
config = self.env["res.config.settings"].create({})
# Should not raise error
config.execute()

View file

@ -11,7 +11,7 @@
<record id="action_product_calculate_theoritical_price" model="ir.actions.server">
<field name="name">Update Sales Price</field>
<field name="model_id" ref="product.model_product_template"/>
<field name="binding_model_id" ref="product.model_product_template"/>
<field name="binding_model_id" ref="product.model_product_template"/>
<field name="state">code</field>
<field name="code">
records.action_update_list_price()
@ -19,4 +19,3 @@
</record>
</odoo>