mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[REF] - Use method _get_quantity_to_invoice.
This commit is contained in:
committed by
Víctor Martínez
parent
78a42762b8
commit
8d73c776fd
@@ -12,44 +12,51 @@ from odoo import exceptions
|
||||
class TestContractVariableQuantity(odoo.tests.HttpCase):
|
||||
def setUp(self):
|
||||
super(TestContractVariableQuantity, self).setUp()
|
||||
self.partner = self.env['res.partner'].create({
|
||||
'name': 'Test partner',
|
||||
})
|
||||
self.product = self.env['product.product'].create({
|
||||
'name': 'Test product',
|
||||
})
|
||||
self.contract = self.env['account.analytic.account'].create({
|
||||
'name': 'Test Contract',
|
||||
'partner_id': self.partner.id,
|
||||
'pricelist_id': self.partner.property_product_pricelist.id,
|
||||
'recurring_invoices': True,
|
||||
})
|
||||
self.formula = self.env['contract.line.qty.formula'].create({
|
||||
'name': 'Test formula',
|
||||
# For testing each of the possible variables
|
||||
'code': 'env["res.users"]\n'
|
||||
'context.get("lang")\n'
|
||||
'user.id\n'
|
||||
'line.qty_type\n'
|
||||
'contract.id\n'
|
||||
'invoice.id\n'
|
||||
'result = 12',
|
||||
})
|
||||
self.contract_line = self.env['account.analytic.invoice.line'].create({
|
||||
'contract_id': self.contract.id,
|
||||
'product_id': self.product.id,
|
||||
'name': 'Test',
|
||||
'qty_type': 'variable',
|
||||
'qty_formula_id': self.formula.id,
|
||||
'quantity': 1,
|
||||
'uom_id': self.product.uom_id.id,
|
||||
'price_unit': 100,
|
||||
'discount': 50,
|
||||
'recurring_rule_type': 'monthly',
|
||||
'recurring_interval': 1,
|
||||
'date_start': '2016-02-15',
|
||||
'recurring_next_date': '2016-02-29',
|
||||
})
|
||||
self.partner = self.env['res.partner'].create({'name': 'Test partner'})
|
||||
self.product = self.env['product.product'].create(
|
||||
{'name': 'Test product'}
|
||||
)
|
||||
self.contract = self.env['account.analytic.account'].create(
|
||||
{
|
||||
'name': 'Test Contract',
|
||||
'partner_id': self.partner.id,
|
||||
'pricelist_id': self.partner.property_product_pricelist.id,
|
||||
'recurring_invoices': True,
|
||||
}
|
||||
)
|
||||
self.formula = self.env['contract.line.qty.formula'].create(
|
||||
{
|
||||
'name': 'Test formula',
|
||||
# For testing each of the possible variables
|
||||
'code': 'env["res.users"]\n'
|
||||
'context.get("lang")\n'
|
||||
'user.id\n'
|
||||
'line.qty_type\n'
|
||||
'contract.id\n'
|
||||
'quantity\n'
|
||||
'period_first_date\n'
|
||||
'period_last_date\n'
|
||||
'invoice_date\n'
|
||||
'result = 12',
|
||||
}
|
||||
)
|
||||
self.contract_line = self.env['account.analytic.invoice.line'].create(
|
||||
{
|
||||
'contract_id': self.contract.id,
|
||||
'product_id': self.product.id,
|
||||
'name': 'Test',
|
||||
'qty_type': 'variable',
|
||||
'qty_formula_id': self.formula.id,
|
||||
'quantity': 1,
|
||||
'uom_id': self.product.uom_id.id,
|
||||
'price_unit': 100,
|
||||
'discount': 50,
|
||||
'recurring_rule_type': 'monthly',
|
||||
'recurring_interval': 1,
|
||||
'date_start': '2016-02-15',
|
||||
'recurring_next_date': '2016-02-29',
|
||||
}
|
||||
)
|
||||
|
||||
def test_check_invalid_code(self):
|
||||
with self.assertRaises(exceptions.ValidationError):
|
||||
|
||||
Reference in New Issue
Block a user