Skip to Content
Menu
This question has been flagged
1 Reply
1455 Views

I have created a custom module, custom_module, that adds a field to res.partner via model

________

class MyModule(models.Model)

    _inherit = 'res_partner'

    card_on_file = fields.Boolean(string='Payment on File', store=True)

------

I'd like to have the status of this field update a related field on quotations but am not sure how to add it properly to be available to call it on sale.order.form 

Is the below the way to do this?

______

class MyQuoMod(models.Model)

    _inherit = 'sale.order'

    card_on_file = fields.Boolean(string='Payment on File', related=res.partner.card_on_file')

Thank you for your time.

Avatar
Discard
Best Answer

You need to use the partner_id to reference the related field like so.

card_on_file = fields.Boolean(string='Payment on File', related='partner_id.card_on_file')

You also need to fix the typo in the MyModule class. _inherit should be res.partner instead of res_partner


Avatar
Discard
Author

Paresh, thank you this is working well. I am wondering what I'd need to do in order to have the field in either module updateable? Right now only module1 is the editable one. What would i have to do/add in order to be able to update from module2 to module1 without jumping back and forth between forms?

For Instance:

module1

card_on_file = fields.Boolean(string='Payment on File', store=True)

module2

card_on_file = fields.Boolean(string='Payment on File', related='module1.card_on_file')

So how would I go about adding the ability to check the card_on_file field in either module1 or module2 to update each other? I'm thinking I'd need another module that sits between them?

Try setting "store=True" on the related field too (i.e. make both of them stored fields)