Skip to Content
Menu
This question has been flagged

I added 'A' attribute to sale.order model. I want the server to suggest a particular value for field A (value is computed in a function) based on partner_id value But I want it to be editable and I want no change to occur to already existing records as a result I cant use compute and inverse. what should I do?

thanks in advance.

Avatar
Discard
Author Best Answer

done it like this:

class SaleOrderInherit(models.Model):
_inherit = 'sale.order'

A = fields.Char(string="A", required=True)
@api.onchange('partner_id')
def _set_A(self):
for r in self:
if not r.partner_id:
r.A = ''
else:
            // my case

Avatar
Discard
Related Posts Replies Views Activity
1
May 24
1077
0
Jan 24
169
1
Aug 21
1319
1
Sep 24
214
2
Apr 24
3049