Skip to content

Commit

Permalink
[16.0][IMP] purchase_order_line_product_brand_info: Change compute fo…
Browse files Browse the repository at this point in the history
…r onchange.
  • Loading branch information
Berezi committed Dec 5, 2024
1 parent 8445646 commit 34b6a1f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 56 deletions.
2 changes: 1 addition & 1 deletion purchase_order_line_product_brand_info/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"website": "https://github.com/avanzosc/odoo-addons",
"author": "Avanzosc",
"license": "AGPL-3",
"depends": ["purchase", "product_brand_supplierinfo"],
"depends": ["purchase", "product_brand_supplierinfo", "purchase_order_line_seller"],
"data": [
"report/purchase_order_report.xml",
"views/purchase_order_line_views.xml",
Expand Down
10 changes: 5 additions & 5 deletions purchase_order_line_product_brand_info/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-05-27 11:05+0000\n"
"PO-Revision-Date: 2024-05-27 11:05+0000\n"
"POT-Creation-Date: 2024-12-05 14:22+0000\n"
"PO-Revision-Date: 2024-12-05 14:22+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -22,9 +22,9 @@ msgid "<strong>Brand Code</strong>"
msgstr "<strong>Código marca</strong>"

#. module: purchase_order_line_product_brand_info
#: model:ir.model.fields,field_description:purchase_order_line_product_brand_info.field_purchase_order_line__brand_fabricators
msgid "Brand Fabricators"
msgstr "Fabricantes marca"
#: model:ir.model.fields,field_description:purchase_order_line_product_brand_info.field_purchase_order_line__product_brand_id
msgid "Product Brand"
msgstr "Marca"

#. module: purchase_order_line_product_brand_info
#: model:ir.model.fields,field_description:purchase_order_line_product_brand_info.field_purchase_order_line__product_brand_code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-05-27 11:05+0000\n"
"PO-Revision-Date: 2024-05-27 11:05+0000\n"
"POT-Creation-Date: 2024-12-05 14:22+0000\n"
"PO-Revision-Date: 2024-12-05 14:22+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -22,8 +22,8 @@ msgid "<strong>Brand Code</strong>"
msgstr ""

#. module: purchase_order_line_product_brand_info
#: model:ir.model.fields,field_description:purchase_order_line_product_brand_info.field_purchase_order_line__brand_fabricators
msgid "Brand Fabricators"
#: model:ir.model.fields,field_description:purchase_order_line_product_brand_info.field_purchase_order_line__product_brand_id
msgid "Product Brand"
msgstr ""

#. module: purchase_order_line_product_brand_info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,13 @@
class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"

product_brand_code = fields.Char(
compute="_compute_brand_info",
store=True,
copy=False,
)
brand_fabricators = fields.Char(
compute="_compute_brand_info",
store=True,
copy=False,
)
product_brand_code = fields.Char()
product_brand_id = fields.Many2one(comodel_name="product.brand")

@api.depends(
"product_id",
"product_id.product_tmpl_id",
"product_id.product_tmpl_id.seller_ids",
"product_id.product_tmpl_id.seller_ids.partner_id",
"product_id.product_tmpl_id.seller_ids.product_brand_id",
"product_id.product_tmpl_id.seller_ids.product_brand_id.code",
"product_id.product_tmpl_id.seller_ids.product_brand_id",
)
def _compute_brand_info(self):
for move in self:
product_brand_code = ""
brand_fabricators = ""
if move.product_id:
sellers = move.product_id.seller_ids.filtered(
lambda x: x.product_brand_id and x.product_brand_id.code
)
for seller in sellers:
brand_code = seller.product_brand_id.code
product_brand_code = (
brand_code
if not product_brand_code
else "{}, {}".format(product_brand_code, brand_code)
)
partner_name = seller.partner_id.name
brand_fabricators = (
partner_name
if not brand_fabricators
else "{}, {}".format(brand_fabricators, partner_name)
)
move.product_brand_code = product_brand_code
move.brand_fabricators = brand_fabricators
@api.onchange("seller_id")
def onchange_seller_id(self):
super().onchange_seller_id()
if self.seller_id.brand_code:
self.product_brand_code = self.seller_id.brand_code
if self.seller_id.product_brand_id:
self.product_brand_id = self.seller_id.product_brand_id.id
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<field name="arch" type="xml">
<field name="date_planned" position="after">
<field name="product_brand_code" optional="show" readonly="1" />
<field name="brand_fabricators" optional="show" readonly="1" />
<field name="product_brand_id" optional="show" readonly="1" />
</field>
</field>
</record>
Expand All @@ -17,7 +17,7 @@
<field name="arch" type="xml">
<field name="price_unit" position="after">
<field name="product_brand_code" readonly="1" />
<field name="brand_fabricators" readonly="1" />
<field name="product_brand_id" readonly="1" />
</field>
</field>
</record>
Expand All @@ -28,7 +28,7 @@
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="product_brand_code" />
<field name="brand_fabricators" />
<field name="product_brand_id" />
</field>
</field>
</record>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
position="after"
>
<field name="product_brand_code" optional="show" readonly="1" />
<field name="brand_fabricators" optional="show" readonly="1" />
<field name="product_brand_id" optional="show" readonly="1" />
</xpath>
</field>
</record>
Expand Down

0 comments on commit 34b6a1f

Please sign in to comment.