[FIX] purchase(_product_matrix): no_variant attributes
Display no variant infos in the purchase order line description. closes odoo/odoo#35717 Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
This commit is contained in:
@@ -614,9 +614,7 @@ class PurchaseOrderLine(models.Model):
|
||||
partner_id=self.partner_id.id,
|
||||
company_id=self.company_id.id,
|
||||
)
|
||||
self.name = product_lang.display_name
|
||||
if product_lang.description_purchase:
|
||||
self.name += '\n' + product_lang.description_purchase
|
||||
self.name = self._get_product_purchase_description(product_lang)
|
||||
|
||||
self._compute_tax_id()
|
||||
|
||||
@@ -693,6 +691,14 @@ class PurchaseOrderLine(models.Model):
|
||||
else:
|
||||
self.product_qty = 1.0
|
||||
|
||||
def _get_product_purchase_description(self, product_lang):
|
||||
self.ensure_one()
|
||||
name = product_lang.display_name
|
||||
if product_lang.description_purchase:
|
||||
name += '\n' + product_lang.description_purchase
|
||||
|
||||
return name
|
||||
|
||||
def _prepare_account_move_line(self, move):
|
||||
self.ensure_one()
|
||||
if self.product_id.purchase_method == 'purchase':
|
||||
|
||||
@@ -88,14 +88,11 @@ class PurchaseOrder(models.Model):
|
||||
if not default_po_line_vals:
|
||||
OrderLine = self.env['purchase.order.line']
|
||||
default_po_line_vals = OrderLine.default_get(OrderLine._fields.keys())
|
||||
pnvav = [] # product no variant attribute values
|
||||
for nvav in no_variant_attribute_values:
|
||||
pnvav.append((4, nvav))
|
||||
new_lines.append((0, 0, dict(
|
||||
default_po_line_vals,
|
||||
product_id=product.id,
|
||||
product_qty=qty,
|
||||
product_no_variant_attribute_value_ids=pnvav)
|
||||
product_no_variant_attribute_value_ids=no_variant_attribute_values.ids)
|
||||
))
|
||||
if new_lines:
|
||||
self.update(dict(order_line=new_lines))
|
||||
@@ -146,3 +143,10 @@ class PurchaseOrderLine(models.Model):
|
||||
is_configurable_product = fields.Boolean('Is the product configurable?', related="product_template_id.has_configurable_attributes")
|
||||
product_template_attribute_value_ids = fields.Many2many(related='product_id.product_template_attribute_value_ids', readonly=True)
|
||||
product_no_variant_attribute_value_ids = fields.Many2many('product.template.attribute.value', string='Product attribute values that do not create variants')
|
||||
|
||||
def _get_product_purchase_description(self, product):
|
||||
name = super(PurchaseOrderLine, self)._get_product_purchase_description(product)
|
||||
for no_variant_attribute_value in self.product_no_variant_attribute_value_ids:
|
||||
name += "\n" + no_variant_attribute_value.attribute_id.name + ': ' + no_variant_attribute_value.name
|
||||
|
||||
return name
|
||||
|
||||
Reference in New Issue
Block a user