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

I have 3 fields, force_date and min_date inherited from stock.picking and date_invoice from account.invoice. I want that if I update the force_date, it will execute to the date_invoice also, which in result the date_invoice will equals to force_date.



Class Picking (models.Model):

_inherit = 'stock.picking'

force_date = fields.DateTime ()
min_date = fields.Datetime ('Please Change it')


@ api.multi
def write (self, vals):
#vals ['min_date'] = self.force_date
# print ("Min_Date" + vals ['min_date'])

vals ['min_date'] = vals ['force_date']
print ("Min_date Vals" + vals ['min_date'])
print ("ForceDate Vals" + vals ['force_date'])
print ("ForceDate" + self.force_date)
print (" Test the Edit Button ")
record = super (Picking, self) .write (vals)
print (record)
return record


​class AccountInvoice(models.Model):
_name = 'stock.picking'
_inherit = 'account.invoice'

force_date = fields.Datetime("Your Force Date")
date_invoice = fields.Date("This is invoice",related="force_date")



I tried to use this but I got "KeyError: 'backorder_id'"


What should I do?

Avatar
Discard
Best Answer

Hello,

date_invoice = fields.Date("This is invoice",related="force_date")

Please pass many2one field link of stock.picking in above field date will change.

Avatar
Discard
Related Posts Replies Views Activity
5
Jun 21
15756
3
Dec 22
3500
4
Sep 19
3770
0
Mar 15
3569
1
Aug 23
1927