mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[FIX] account_invoice_margin: migrate and update
Updated field 'type' to 'move_type' in test test_invoice_margin. Updated methods product_id_change_margin and create override so they pass tests in odoo 14.0. H4396
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
from odoo import api, fields, models
|
||||
from odoo.addons import decimal_precision as dp
|
||||
|
||||
|
||||
class AccountMoveLine(models.Model):
|
||||
@@ -26,13 +25,15 @@ class AccountMoveLine(models.Model):
|
||||
def product_id_change_margin(self):
|
||||
for line in self:
|
||||
if not line.product_id:
|
||||
return
|
||||
line.purchase_price = line._compute_margin(line.move_id, line.product_id, line.product_uom_id, line.sale_line_ids)
|
||||
line.purchase_price = 0
|
||||
else:
|
||||
line.purchase_price = line._compute_margin(line.move_id, line.product_id, line.product_uom_id, line.sale_line_ids)
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals):
|
||||
line = super(AccountMoveLine, self).create(vals)
|
||||
line.product_id_change_margin()
|
||||
if 'purchase_price' not in vals[0]:
|
||||
line.product_id_change_margin()
|
||||
return line
|
||||
|
||||
@api.depends('product_id', 'purchase_price', 'quantity', 'price_unit', 'price_subtotal')
|
||||
|
||||
@@ -47,7 +47,7 @@ class TestInvoiceMargin(TestSaleMargin):
|
||||
|
||||
account = self.env['account.account'].search([('internal_type', '=', 'other')], limit=1)
|
||||
inv = self.AccountMove.create({
|
||||
'type': 'in_invoice',
|
||||
'move_type': 'in_invoice',
|
||||
'partner_id': self.partner_id,
|
||||
'invoice_line_ids': [
|
||||
(0, 0, {
|
||||
|
||||
Reference in New Issue
Block a user