Skip to Content
Menu
This question has been flagged
3 Replies
10243 Zobrazenia

I am trying to replicate the behaviour of the sales order line items.  What I would like to do is this.

When the user selects a product from the drop down that is linked back to the product part number, copy the description field for that product into the description field on the line item.  I don't want to use  a related field because sometime the description might have to be customized.

I am trying to do this with python code in an automated action but I'm new to this and am confused on how to get a value from a field in another model.

I am using the SaaS version of Odoo.

Trigger Condition = Based on form modification

onChange fields trigger = x_part_num

I've tried several things in my python code but to no avail.  I'm trying to do something like this

record['x_description'] = partModel.description   (obviously this is just pseudo code as an example of what i'm trying to achieve).

Any mentoring and advice is appreciated.


Avatar
Zrušiť

Your use case description is not understandable. Please try to define it clear and concise and provide your code.

Autor Best Answer

I figured it out myself. In case someone might find it useful here is what I did. You might want to ask for more details before just closing the post!

So I have figured out a way to do it, but I'm not sure if this is the right approach. Any feedback or advice is welcomed

In my automated action I wrote the following python code.

ref_model = env['x_parts']
ref_record = ref_model.browse(record.x_part_num.id)
record['x_bom_description']= ref_record.x_descriptions

Hopefully someone like me who is looking for help will find this useful.

Avatar
Zrušiť

Hello! I have a similar case but its not working.
Model: Work Order
Trigger field: Operation (Work Order)

My python code is:

ref_model = env['mrp.routing.workcenter']
ref_record = ref_model.browse(record.id.id)
record['x_studio_field']= ref_record.x_studio_fieldtocopy

Any advice would be appreciated! thanks!

mcd, i dont think we have kind of relation record.id.id
It should be something like record.<some m2o field>.id

Related Posts Replies Zobrazenia Aktivita
1
feb 21
4428
3
jún 20
5111
0
jún 20
2683
0
feb 16
3788
0
mar 18
3109