- 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
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
# Copyright 2025 Criptomart
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
|
|
|
from odoo import _
|
|
from odoo import api
|
|
from odoo import fields
|
|
from odoo import models
|
|
|
|
|
|
class ProductProduct(models.Model):
|
|
_inherit = "product.product"
|
|
|
|
group_order_ids = fields.Many2many(
|
|
"group.order",
|
|
"group_order_product_rel",
|
|
"product_id",
|
|
"order_id",
|
|
string="Group Orders",
|
|
readonly=True,
|
|
help="Group orders where this product is available",
|
|
)
|
|
|
|
@api.model
|
|
def _get_products_for_group_order(self, order_id):
|
|
"""Backward-compatible delegation to `group.order` discovery.
|
|
|
|
The canonical discovery logic lives on `group.order` to keep
|
|
responsibilities together. Keep this wrapper so existing callers
|
|
on `product.product` keep working.
|
|
"""
|
|
order = self.env["group.order"].browse(order_id)
|
|
if not order.exists():
|
|
return self.browse()
|
|
return order._get_products_for_group_order(order.id)
|
|
|
|
|
|
class ProductTemplate(models.Model):
|
|
_inherit = "product.template"
|
|
|
|
group_order_ids = fields.Many2many(
|
|
"group.order",
|
|
compute="_compute_group_order_ids",
|
|
string="Consumer Group Orders",
|
|
readonly=True,
|
|
help="Consumer group orders where variants of this product are available",
|
|
)
|
|
|
|
@api.depends("product_variant_ids.group_order_ids")
|
|
def _compute_group_order_ids(self):
|
|
for template in self:
|
|
variants = template.product_variant_ids
|
|
template.group_order_ids = variants.mapped("group_order_ids")
|