mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[FIX] - Fix unit tests
This commit is contained in:
committed by
Víctor Martínez
parent
c42fba6b2e
commit
5d5fb6757b
@@ -14,7 +14,8 @@ class AccountAnalyticInvoiceLine(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def _prepare_invoice_line(self, invoice_id=False):
|
def _prepare_invoice_line(self, invoice_id=False):
|
||||||
vals = super(AccountAnalyticInvoiceLine, self)._prepare_invoice_line(
|
vals = super(AccountAnalyticInvoiceLine, self)._prepare_invoice_line(
|
||||||
invoice_id=invoice_id)
|
invoice_id=invoice_id
|
||||||
|
)
|
||||||
if self.qty_type == 'variable':
|
if self.qty_type == 'variable':
|
||||||
eval_context = {
|
eval_context = {
|
||||||
'env': self.env,
|
'env': self.env,
|
||||||
@@ -22,23 +23,28 @@ class AccountAnalyticInvoiceLine(models.Model):
|
|||||||
'user': self.env.user,
|
'user': self.env.user,
|
||||||
'line': self,
|
'line': self,
|
||||||
'contract': self.contract_id,
|
'contract': self.contract_id,
|
||||||
|
'invoice': self.env['account.invoice'].browse(invoice_id),
|
||||||
}
|
}
|
||||||
if invoice_id:
|
safe_eval(
|
||||||
eval_context['invoice'] = self.env['account.invoice'].browse(
|
self.qty_formula_id.code.strip(),
|
||||||
invoice_id),
|
eval_context,
|
||||||
safe_eval(self.qty_formula_id.code.strip(), eval_context,
|
mode="exec",
|
||||||
mode="exec", nocopy=True) # nocopy for returning result
|
nocopy=True,
|
||||||
|
) # nocopy for returning result
|
||||||
qty = eval_context.get('result', 0)
|
qty = eval_context.get('result', 0)
|
||||||
if self.contract_id.skip_zero_qty and float_is_zero(
|
if self.contract_id.skip_zero_qty and float_is_zero(
|
||||||
qty, self.env['decimal.precision'].precision_get(
|
qty,
|
||||||
'Product Unit of Measure')):
|
self.env['decimal.precision'].precision_get(
|
||||||
|
'Product Unit of Measure'
|
||||||
|
),
|
||||||
|
):
|
||||||
# Return empty dict to skip line create
|
# Return empty dict to skip line create
|
||||||
vals = {}
|
vals = {}
|
||||||
else:
|
else:
|
||||||
vals['quantity'] = qty
|
vals['quantity'] = qty
|
||||||
# Re-evaluate price with this new quantity
|
# Re-evaluate price with this new quantity
|
||||||
vals['price_unit'] = self.with_context(
|
vals['price_unit'] = self.with_context(
|
||||||
contract_line_qty=qty,
|
contract_line_qty=qty
|
||||||
).price_unit
|
).price_unit
|
||||||
else:
|
else:
|
||||||
if vals.get('quantity') and vals['quantity'] == 0:
|
if vals.get('quantity') and vals['quantity'] == 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user