Skip to Content
Menu
This question has been flagged
1 Atsakyti
3655 Rodiniai

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?

Portretas
Atmesti
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.

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
5
birž. 21
17853
3
gruod. 22
4523
4
rugs. 19
4923
0
kov. 15
4347
1
rugp. 23
3888