Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
10240 Widoki

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.


Awatar
Odrzuć

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

Autor Najlepsza odpowiedź

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.

Awatar
Odrzuć

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

Powiązane posty Odpowiedzi Widoki Czynność
1
lut 21
4427
3
cze 20
5106
0
cze 20
2680
0
lut 16
3786
0
mar 18
3107