|
@@ -9,11 +9,12 @@ class account_invoice(models.Model):
|
|
|
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()})
|
|
|
+ if item.purchase_line_id:
|
|
|
+ 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
|