[FIX] mrp: show correct number of attachments on bom lines
Display a BoM. On BoM lines, there is an attachment feature that creates a mrp.document, which is basically a container for an attachment. This commit fixes the view which displayed 'no attachment' when there were some and vice versa. It also fixes the computation of the number of attachment: the displayed view is on mrp.document, but the computation is done on ir.attachment. As a result if there are other unrelated attachments (such as digital files) they would be counted but not displayed. opw 1923441 closes odoo/odoo#30208
This commit is contained in:
@@ -261,7 +261,7 @@ class MrpBomLine(models.Model):
|
||||
@api.one
|
||||
@api.depends('product_id')
|
||||
def _compute_has_attachments(self):
|
||||
nbr_attach = self.env['ir.attachment'].search_count([
|
||||
nbr_attach = self.env['mrp.document'].search_count([
|
||||
'|',
|
||||
'&', ('res_model', '=', 'product.product'), ('res_id', '=', self.product_id.id),
|
||||
'&', ('res_model', '=', 'product.template'), ('res_id', '=', self.product_id.product_tmpl_id.id)])
|
||||
|
||||
@@ -62,8 +62,8 @@
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="product_id" context="{'default_type': 'product'}"/>
|
||||
<field name="has_attachments" invisible="1"/>
|
||||
<button name="action_see_attachments" type="object" icon="fa-files-o" attrs="{'invisible': [('has_attachments', '=', False)]}" aria-label="No attachment" title="No attachment"/>
|
||||
<button name="action_see_attachments" type="object" icon="fa-file" attrs="{'invisible': [('has_attachments', '=', True)]}" aria-label="Attachments" title="Attachments"/>
|
||||
<button name="action_see_attachments" type="object" icon="fa-files-o" attrs="{'invisible': [('has_attachments', '=', True)]}" aria-label="No attachment" title="No attachment"/>
|
||||
<button name="action_see_attachments" type="object" icon="fa-file" attrs="{'invisible': [('has_attachments', '=', False)]}" aria-label="Attachments" title="Attachments"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="parent_product_tmpl_id" invisible="1" />
|
||||
<field name="product_uom_id" options="{'no_open':True,'no_create':True}" groups="uom.group_uom"/>
|
||||
|
||||
Reference in New Issue
Block a user