Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
4501 Vizualizări

Hi guys,


I have the following scenario:

- Each product we make is unique

- New products are based off a BoM template

- Each product is priced based off the BoM cost

I want to avoid having to click into the product and click the 'Compute Price from BoM' every time a new product is created.

How can I configure an Automated action to 'Compute Price from BoM' whenever a BoM is updated for a product?


Thanks,

Lucas

Imagine profil
Abandonează
Cel mai bun răspuns

In the list view of your bom products. You can select all of them and then click on the action button. In that action button is the compute from BoM action. There you can trigger all at once.


product_template_obj = env['product.template'].search([('id', '=' , record.product_tmpl_id.id)])
product_template_obj.action_bom_cost()

Imagine profil
Abandonează
Autor

Hi Nomad,

I am aware of that method.
The goal is to automatically compute from BoM each time a BoM is updated

thanks,
Lucas

I will try to create automated action for you to use

odoo4Life are you able to make the automate action for this?

Yes Krakalien, the automated action is found in the answer.

Create an automated action on BoM model. which on BoM creation or update, will run the following python code:

#search the database for the product which is linked to the BoM:
product_template_obj = env['product.template'].search([('id', '=' , record.product_tmpl_id.id)])

#Trigger the BoM compute button on the product you just searched:
product_template_obj.action_bom_cost()

Of course this is maybe for an older version of Odoo than what you are currently using.

odoo4life
i am getting this error
raise ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr))
ValueError: <class 'AttributeError'>: "'product.template' object has no attribute 'product_tmpl_id'" while evaluating
"product_template_obj = env['product.template'].search([('id', '=' , record.product_tmpl_id.id)])\r\nproduct_template_obj.action_bom_cost()"

regards

Krakalien,

This automated action should be applied/implemented for model: mrp.bom.

Model: mrp.bom
Trigger: on creation and update
Action: Python code

for record in records:
product_template_obj = env['product.template'].search([('id', '=' , record.product_tmpl_id.id)])
product_template_obj.action_bom_cost()

Related Posts Răspunsuri Vizualizări Activitate
0
sept. 24
1156
0
mai 24
26
0
mar. 24
1448
0
mar. 24
1547
0
mar. 24
21