update_date.py
1.2 KB
#coding=utf-8
from odoo import models,fields,api, _
import datetime
import logging
from odoo.exceptions import UserError, ValidationError
_logger = logging.getLogger(__name__)
class UpdateDate(models.TransientModel):
_name = "update.date"
date_due = fields.Date(string='到期日期',required=True)
@api.multi
def update_date_due(self):
date_due = self.date_due
context = dict(self._context or {})
active_id = context.get('active_id', False)
# if active_id:
# before_model = self.env['before.purchase'].browse(active_id)
# for line in before_model.order_line:
# if line.brand == brand:
# line.write()
if active_id:
active_model = self.env['account.invoice'].browse(active_id)
# cr = self.env.cr
# cr.execute("""
# UPDATE account_invoice
# SET partner_id = %s
# WHERE
# brand = '%s'
# AND order_id = %s
# """% (partner_id.id,brand,active_id)
# )
active_model.write({'date_due':date_due})
return True