Skip to Content
Menu
This question has been flagged
3 Replies
2280 Views
# -*- Coding: utf-8 -*-

from odoo import models, fields, api, _
from odoo.exceptions import ValidationError, UserError

class PickingType(models.Model):
_inherit = 'stock.picking.type'

@api.multi
def date_done(self):
temp_pickings = self.env['stock.picking'].search([(partner_id, '=', self.partner_id.id)], order='date_done desc', limit=1)
for picking in temp_pickings:
picking.partner_id.last_delivery_date = picking.date_done
super(PickingType, self).date_done(self)
Above Code is write but not working.
Avatar
Discard

is the function getting executed ? if so try writing into database using the write

picking.partner_id.write({'last_delivery_date': picking.date_done})

Thanks for your reply. Actually function not getting executed. Requested to just guide me about one line code, how I get the function execute?


From: Niyas Raphy <niyasraphyk@gmail.com>
Sent: Thursday, May 23, 2019 8:42 PM
To: Sueb
Subject: Re: How to write the date_done of picking in res_partner as last_delivery_date?
 

is the function getting executed ? if so try writing into database using the write

picking.partner_id.write({'last_delivery_date': picking.date_done})

Sent by Odoo S.A. using Odoo.

Author Best Answer
# -*- Coding: utf-8 -*-

from odoo import fields, api, models

class StockMoves(models.Model):
_inherit = 'stock.move'

@api.multi
def action_done(self):
pickings = self.env['stock.picking'].search([('partner_id', '=', self.partner_id.id)], order='date_done desc', limit=1)
print type(pickings)
for picking in pickings:
print (picking.partner_id.last_delivery_date)
picking.partner_id.write({'last_delivery_date': fields.Datetime.now()})
res = super(StockMoves, self).action_done()
return res

Avatar
Discard