Skip to content
Snippets Groups Projects
Commit 25912970 authored by Jérome Maes's avatar Jérome Maes
Browse files

[FIX] sale: name_get of SO line

This commit format the display_name of sale.order.line,
without context key.
The webclient trigger the name_search with context
key, but display the field without it.
So on task form view, when searching an SO line, user
will see 'SO0001 - my product' in its dropdown, but the
complete SO line description when saving.
This commit proposes, in aggreement with AL and FP, to
a global (and non conditionnal) format, since it seems
task form view is the only one place requiring the SO
line name_get.
parent 43509423
No related branches found
No related tags found
No related merge requests found
......@@ -1067,23 +1067,21 @@ class SaleOrderLine(models.Model):
@api.multi
def name_get(self):
if self._context.get('sale_show_order_product_name'):
result = []
for so_line in self:
name = '%s - %s' % (so_line.order_id.name, so_line.product_id.name)
result.append((so_line.id, name))
return result
return super(SaleOrderLine, self).name_get()
result = []
for so_line in self:
name = '%s - %s' % (so_line.order_id.name, so_line.name.split('\n')[0] or so_line.product_id.name)
if so_line.order_partner_id.ref:
name = '%s (%s)' % (name, so_line.order_partner_id.ref)
result.append((so_line.id, name))
return result
@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
if self._context.get('sale_show_order_product_name'):
if operator in ('ilike', 'like', '=', '=like', '=ilike'):
domain = expression.AND([
args or [],
['|', ('order_id.name', operator, name), ('name', operator, name)]
])
return self.search(domain, limit=limit).name_get()
if operator in ('ilike', 'like', '=', '=like', '=ilike'):
args = expression.AND([
args or [],
['|', ('order_id.name', operator, name), ('name', operator, name)]
])
return super(SaleOrderLine, self).name_search(name, args, operator, limit)
@api.multi
......
......@@ -29,7 +29,7 @@
string="Sales Order"/>
</xpath>
<field name="user_id" position="after">
<field name="sale_line_id" string="Sales Order Item" attrs="{'invisible': [('partner_id', '=', False)], 'readonly': [('parent_id', '!=', False)]}" options='{"no_open": True, "no_create": True}' context="{'sale_show_order_product_name': True}"/>
<field name="sale_line_id" string="Sales Order Item" attrs="{'invisible': [('partner_id', '=', False)], 'readonly': [('parent_id', '!=', False)]}" options='{"no_open": True, "no_create": True}'/>
</field>
</field>
</record>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment