[IMP] contract_variable_quantity: black, isort, prettier

This commit is contained in:
Carlos Roca
2020-10-27 13:35:26 +01:00
committed by Víctor Martínez
parent fc1955b554
commit 8b7e3b4213
12 changed files with 190 additions and 166 deletions

View File

@@ -12,48 +12,46 @@ 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['contract.contract'].create(
self.partner = self.env["res.partner"].create({"name": "Test partner"})
self.product = self.env["product.product"].create({"name": "Test product"})
self.contract = self.env["contract.contract"].create(
{
'name': 'Test Contract',
'partner_id': self.partner.id,
'pricelist_id': self.partner.property_product_pricelist.id,
"name": "Test Contract",
"partner_id": self.partner.id,
"pricelist_id": self.partner.property_product_pricelist.id,
}
)
self.formula = self.env['contract.line.qty.formula'].create(
self.formula = self.env["contract.line.qty.formula"].create(
{
'name': 'Test formula',
"name": "Test formula",
# For testing each of the possible variables
'code': 'env["res.users"]\n'
"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',
"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['contract.line'].create(
self.contract_line = self.env["contract.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',
"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",
}
)
@@ -71,7 +69,7 @@ class TestContractVariableQuantity(odoo.tests.HttpCase):
self.assertEqual(invoice.invoice_line_ids[0].quantity, 12)
def test_check_skip_zero_qty(self):
self.formula.code = 'result=0'
self.formula.code = "result=0"
self.contract.skip_zero_qty = True
invoice = self.contract.recurring_create_invoice()
self.assertFalse(invoice.invoice_line_ids)