diff --git a/purchase_order_line_product_brand_info/__manifest__.py b/purchase_order_line_product_brand_info/__manifest__.py
index 7de545ceae..13784eca07 100644
--- a/purchase_order_line_product_brand_info/__manifest__.py
+++ b/purchase_order_line_product_brand_info/__manifest__.py
@@ -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",
diff --git a/purchase_order_line_product_brand_info/i18n/es.po b/purchase_order_line_product_brand_info/i18n/es.po
index fba90e4dd1..e89f1eb8aa 100644
--- a/purchase_order_line_product_brand_info/i18n/es.po
+++ b/purchase_order_line_product_brand_info/i18n/es.po
@@ -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"
@@ -22,9 +22,9 @@ msgid "Brand Code"
msgstr "Código marca"
#. 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
diff --git a/purchase_order_line_product_brand_info/i18n/purchase_order_line_product_brand_info.pot b/purchase_order_line_product_brand_info/i18n/purchase_order_line_product_brand_info.pot
index 7a4ef08dec..0826f77294 100644
--- a/purchase_order_line_product_brand_info/i18n/purchase_order_line_product_brand_info.pot
+++ b/purchase_order_line_product_brand_info/i18n/purchase_order_line_product_brand_info.pot
@@ -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"
@@ -22,8 +22,8 @@ msgid "Brand Code"
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
diff --git a/purchase_order_line_product_brand_info/models/purchase_order_line.py b/purchase_order_line_product_brand_info/models/purchase_order_line.py
index 512c3b4538..e345cfb0aa 100644
--- a/purchase_order_line_product_brand_info/models/purchase_order_line.py
+++ b/purchase_order_line_product_brand_info/models/purchase_order_line.py
@@ -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
diff --git a/purchase_order_line_product_brand_info/views/purchase_order_line_views.xml b/purchase_order_line_product_brand_info/views/purchase_order_line_views.xml
index 1b386c6dec..10e29e355e 100644
--- a/purchase_order_line_product_brand_info/views/purchase_order_line_views.xml
+++ b/purchase_order_line_product_brand_info/views/purchase_order_line_views.xml
@@ -6,7 +6,7 @@
-
+
@@ -17,7 +17,7 @@
-
+
@@ -28,7 +28,7 @@
-
+
diff --git a/purchase_order_line_product_brand_info/views/purchase_order_views.xml b/purchase_order_line_product_brand_info/views/purchase_order_views.xml
index 68acbe08db..1d6d48a88a 100644
--- a/purchase_order_line_product_brand_info/views/purchase_order_views.xml
+++ b/purchase_order_line_product_brand_info/views/purchase_order_views.xml
@@ -9,7 +9,7 @@
position="after"
>
-
+