diff --git a/contract_variable_quantity/__manifest__.py b/contract_variable_quantity/__manifest__.py index 514044bb..fcc96103 100644 --- a/contract_variable_quantity/__manifest__.py +++ b/contract_variable_quantity/__manifest__.py @@ -1,10 +1,11 @@ # Copyright 2016-2018 Tecnativa - Pedro M. Baeza # Copyright 2018 Tecnativa - Carlos Dauden +# Copyright 2019 ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Variable quantity in contract recurrent invoicing', - 'version': '12.0.1.0.0', + 'version': '12.0.2.0.0', 'category': 'Contract Management', 'license': 'AGPL-3', 'author': "Tecnativa," @@ -13,11 +14,11 @@ 'depends': ['contract'], 'data': [ 'security/ir.model.access.csv', - 'views/abstract_contract_view.xml', + 'views/abstract_contract_line.xml', 'views/contract_line_formula.xml', - 'views/contract_line_view.xml', - 'views/contract_template_view.xml', - 'views/contract_view.xml', + 'views/contract_line.xml', + 'views/contract_template.xml', + 'views/contract.xml', ], 'installable': True, } diff --git a/contract_variable_quantity/migrations/12.0.2.0.0/pre-migration.py b/contract_variable_quantity/migrations/12.0.2.0.0/pre-migration.py new file mode 100644 index 00000000..69665469 --- /dev/null +++ b/contract_variable_quantity/migrations/12.0.2.0.0/pre-migration.py @@ -0,0 +1,32 @@ +# Copyright 2019 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import logging + +from openupgradelib import openupgrade + +_logger = logging.getLogger(__name__) + + +def migrate(cr, version): + xmlids_to_rename = [ + ('contract_sale.account_analytic_account_own_salesman', + 'contract_sale.contract_contract_own_salesman'), + ('contract_sale.account_analytic_account_see_all', + 'contract_sale.contract_contract_see_all'), + ('contract_sale.account_analytic_contract_salesman', + 'contract_sale.contract_template_salesman'), + ('contract_sale.account_analytic_contract_sale_manager', + 'contract_sale.contract_template_sale_manager'), + ('contract_sale.account_analytic_invoice_line_saleman', + 'contract_sale.contract_line_saleman'), + ('contract_sale.account_analytic_invoice_line_manager', + 'contract_sale.contract_line_manager'), + ('contract_sale.account_analytic_contract_line_salesman', + 'contract_sale.contract_template_line_salesman'), + ('contract_sale.account_analytic_contract_line_manager', + 'contract_sale.contract_template_line_manager'), + ('contract_sale.account_analytic_account_contract_salesman', + 'contract_sale.contract_contract_salesman'), + ] + openupgrade.rename_xmlids(cr, xmlids_to_rename) diff --git a/contract_variable_quantity/models/abstract_contract_line.py b/contract_variable_quantity/models/abstract_contract_line.py index aeb00059..07c4ec12 100644 --- a/contract_variable_quantity/models/abstract_contract_line.py +++ b/contract_variable_quantity/models/abstract_contract_line.py @@ -6,8 +6,8 @@ from odoo import fields, models -class AccountAbstractAnalyticContractLine(models.AbstractModel): - _inherit = 'account.abstract.analytic.contract.line' +class ContractAbstractContractLine(models.AbstractModel): + _inherit = 'contract.abstract.contract.line' qty_type = fields.Selection( selection=[ diff --git a/contract_variable_quantity/models/contract.py b/contract_variable_quantity/models/contract.py index 59b56ce8..b0f6755b 100644 --- a/contract_variable_quantity/models/contract.py +++ b/contract_variable_quantity/models/contract.py @@ -6,8 +6,8 @@ from odoo import fields, models -class AccountAnalyticAccount(models.Model): - _inherit = "account.analytic.account" +class ContractContract(models.Model): + _inherit = "contract.contract" skip_zero_qty = fields.Boolean( string='Skip Zero Qty Lines', diff --git a/contract_variable_quantity/models/contract_line.py b/contract_variable_quantity/models/contract_line.py index 14cbb640..9494e7b4 100644 --- a/contract_variable_quantity/models/contract_line.py +++ b/contract_variable_quantity/models/contract_line.py @@ -9,7 +9,7 @@ from odoo.tools.safe_eval import safe_eval class AccountAnalyticInvoiceLine(models.Model): - _inherit = 'account.analytic.invoice.line' + _inherit = 'contract.line' @api.multi def _get_quantity_to_invoice( diff --git a/contract_variable_quantity/models/contract_line_formula.py b/contract_variable_quantity/models/contract_line_formula.py index 5ab920ac..3493cb97 100644 --- a/contract_variable_quantity/models/contract_line_formula.py +++ b/contract_variable_quantity/models/contract_line_formula.py @@ -20,8 +20,8 @@ class ContractLineFormula(models.Model): 'env': self.env, 'context': self.env.context, 'user': self.env.user, - 'line': self.env['account.analytic.invoice.line'], - 'contract': self.env['account.analytic.account'], + 'line': self.env['contract.line'], + 'contract': self.env['contract.contract'], 'invoice': self.env['account.invoice'], 'quantity': 0, 'period_first_date': False, diff --git a/contract_variable_quantity/tests/test_contract_variable_quantity.py b/contract_variable_quantity/tests/test_contract_variable_quantity.py index 8bf5c1c6..3e295a28 100644 --- a/contract_variable_quantity/tests/test_contract_variable_quantity.py +++ b/contract_variable_quantity/tests/test_contract_variable_quantity.py @@ -16,12 +16,11 @@ class TestContractVariableQuantity(odoo.tests.HttpCase): self.product = self.env['product.product'].create( {'name': 'Test product'} ) - self.contract = self.env['account.analytic.account'].create( + self.contract = self.env['contract.contract'].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( @@ -40,7 +39,7 @@ class TestContractVariableQuantity(odoo.tests.HttpCase): 'result = 12', } ) - self.contract_line = self.env['account.analytic.invoice.line'].create( + self.contract_line = self.env['contract.line'].create( { 'contract_id': self.contract.id, 'product_id': self.product.id, diff --git a/contract_variable_quantity/views/abstract_contract_view.xml b/contract_variable_quantity/views/abstract_contract_line.xml similarity index 70% rename from contract_variable_quantity/views/abstract_contract_view.xml rename to contract_variable_quantity/views/abstract_contract_line.xml index 90a9b12e..68dbccaf 100644 --- a/contract_variable_quantity/views/abstract_contract_view.xml +++ b/contract_variable_quantity/views/abstract_contract_line.xml @@ -1,13 +1,11 @@ - - Account Abstract Analytic Contract Line Form View - - account.abstract.analytic.contract.line - + Abstract Contract Line Form View + contract.abstract.contract.line + diff --git a/contract_variable_quantity/views/contract_view.xml b/contract_variable_quantity/views/contract.xml similarity index 52% rename from contract_variable_quantity/views/contract_view.xml rename to contract_variable_quantity/views/contract.xml index d555b531..9e8231a9 100644 --- a/contract_variable_quantity/views/contract_view.xml +++ b/contract_variable_quantity/views/contract.xml @@ -1,9 +1,9 @@ - - account.analytic.account - + + contract.contract + diff --git a/contract_variable_quantity/views/contract_line_view.xml b/contract_variable_quantity/views/contract_line.xml similarity index 71% rename from contract_variable_quantity/views/contract_line_view.xml rename to contract_variable_quantity/views/contract_line.xml index 0db97743..c5ec91e7 100644 --- a/contract_variable_quantity/views/contract_line_view.xml +++ b/contract_variable_quantity/views/contract_line.xml @@ -1,12 +1,11 @@ - - account.analytic.invoice.line.tree (in contract_variable_quantity) - account.analytic.invoice.line + + contract.line.tree (in contract_variable_quantity) + contract.line + ref="contract.contract_line_form_view"/> diff --git a/contract_variable_quantity/views/contract_template_view.xml b/contract_variable_quantity/views/contract_template.xml similarity index 52% rename from contract_variable_quantity/views/contract_template_view.xml rename to contract_variable_quantity/views/contract_template.xml index cd552957..3deb0bac 100644 --- a/contract_variable_quantity/views/contract_template_view.xml +++ b/contract_variable_quantity/views/contract_template.xml @@ -1,20 +1,20 @@ - + Contract Template Variable Qty - account.analytic.contract - + contract.template + - + - + - + {'required': [('qty_type', '=', 'fixed')], 'invisible': [('qty_type', '!=', 'fixed')]}