i'am added a method in product.template to compute the product name form strings of some custom fields that related to other models , i added store=True to the name field so i can search about it , but when related fields change on their models the filed name dosn't change , so i need to add server action to menuitem called "update product name" which be located on cutome app that the related fields are there ,if i pressed on this menuitem it run the metode of naming and get new updated field on product name how can i do that here is the code
class autopart(models.Model):
_inherit = 'product.template'
@api.multi
@api.depends('item','dsc', 'drc', 'org','car','model', 'manf','year')
def naming(self):
for rec in self:
if rec.year:
rec.name = " ".join(
[rec.item and rec.item.name or "", rec.drc and rec.drc.name or "", rec.dsc and rec.dsc.name or "",
rec.org and rec.org.name or "", rec.manf and rec.manf.name or "", rec.car and rec.car.name or "",
rec.model and rec.model.name or "",rec.year and rec.year.name or ""
])
else:
rec.name = " ".join(
[rec.item and rec.item.name or "", rec.drc and rec.drc.name or "", rec.dsc and rec.dsc.name or "",
rec.org and rec.org.name or "", rec.manf and rec.manf.name or "", rec.car and rec.car.name or "",
rec.model and rec.model.name or "",
])
name = fields.Char(string="Name", compute=naming ,store=True , required=False,)
here is menuitem
<menuitem id="update_products_menu" name="Update products" parent="master.menu_category_main" sequence="1" action="action_update_products"/>
server action
<record id="action_update_products" model="ir.actions.server">
<field name="name">action_update_products</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_updateproducts"/>
<field name="state">code</field>
<field name="code">how can i run naming methode from product.template here</field>
</record>