12345678910111213141516171819 |
- # -*- encoding: utf-8 -*-
- from openerp import models, fields
- from datetime import date
- class account_invoice(models.Model):
- _inherit = 'account.invoice'
- def invoice_validate(self):
- res = super(account_invoice, self).invoice_validate()
- for item in self.invoice_line:
- product = self.env['product.product'].browse(item.product_id.id)
- if product:
- template = self.env['product.template'].browse(product.product_tmpl_id.id)
- if(template.price_change == 'purchase'):
- product.write({'standard_price': item.price_unit, 'last_purchase_date': date.today()})
- else:
- product.write({'last_purchase_date': date.today()})
- return res
|