From 2a029138a95a07ac9fc2e9c1867cbb3367c6e138 Mon Sep 17 00:00:00 2001 From: Dmytro Katyukha Date: Wed, 27 Jun 2018 00:40:12 +0300 Subject: [PATCH 1/4] [FIX] analytic invoice/contract lines inheritance Bug description --------------- `account.analytic.contract.line` inherits `account.analytic.invoice.line` `account.analytic.invoice.line` defines field `analytic_account_id`: - comodel='account.analytic.account' `account.analytic.contract.line` redefines field `analytic_account_id`: - comodel='account.analytic.contract' On attempt to extend `account.analytic.invoice.line` model adding field that depends on `analytic_account_id.date_start` Odoo fails to update, because it adds this field to `account.analytic.contract.line` through inheritance, and `account.analytic.contract` model have no this field. What is done ------------ Change inheritance order: - `account.analytic.invoice.line` inherits `account.analytic.contract.line` - no file renames at this stage (this wil be done in next commit) --- contract/models/account_analytic_contract_line.py | 11 +++++------ contract/models/account_analytic_invoice_line.py | 9 +++++---- contract_variable_quantity/models/contract.py | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/contract/models/account_analytic_contract_line.py b/contract/models/account_analytic_contract_line.py index a18d5dbd..9328178c 100644 --- a/contract/models/account_analytic_contract_line.py +++ b/contract/models/account_analytic_contract_line.py @@ -4,14 +4,13 @@ from odoo import fields, models -class AccountAnalyticContractLine(models.Model): - _name = 'account.analytic.contract.line' - _description = 'Contract Lines' - _inherit = 'account.analytic.invoice.line' +class AccountAnalyticInvoiceLine(models.Model): + _name = 'account.analytic.invoice.line' + _inherit = 'account.analytic.contract.line' analytic_account_id = fields.Many2one( - string='Contract', - comodel_name='account.analytic.contract', + 'account.analytic.account', + string='Analytic Account', required=True, ondelete='cascade', ) diff --git a/contract/models/account_analytic_invoice_line.py b/contract/models/account_analytic_invoice_line.py index 8f547aaf..5eff76aa 100644 --- a/contract/models/account_analytic_invoice_line.py +++ b/contract/models/account_analytic_invoice_line.py @@ -14,8 +14,9 @@ from odoo.exceptions import ValidationError from odoo.tools.translate import _ -class AccountAnalyticInvoiceLine(models.Model): - _name = 'account.analytic.invoice.line' +class AccountAnalyticContractLine(models.Model): + _name = 'account.analytic.contract.line' + _description = 'Contract Lines' _order = "sequence,id" product_id = fields.Many2one( @@ -24,8 +25,8 @@ class AccountAnalyticInvoiceLine(models.Model): required=True, ) analytic_account_id = fields.Many2one( - 'account.analytic.account', - string='Analytic Account', + string='Contract', + comodel_name='account.analytic.contract', required=True, ondelete='cascade', ) diff --git a/contract_variable_quantity/models/contract.py b/contract_variable_quantity/models/contract.py index 1d25df93..dff047a4 100644 --- a/contract_variable_quantity/models/contract.py +++ b/contract_variable_quantity/models/contract.py @@ -45,8 +45,8 @@ class AccountAnalyticAccount(models.Model): return vals -class AccountAnalyticInvoiceLine(models.Model): - _inherit = 'account.analytic.invoice.line' +class AccountAnalyticContractLine(models.Model): + _inherit = 'account.analytic.contract.line' qty_type = fields.Selection( selection=[ From a3da40407cd94de8d1712619d1ae0f94d64f63f8 Mon Sep 17 00:00:00 2001 From: Dmytro Katyukha Date: Thu, 12 Jul 2018 13:33:35 +0300 Subject: [PATCH 2/4] Rename account_analytic_*_line files In previous commit changed inheritance order of 'account.analytic.*.line' models, thus classes and models were renamed. This commit only renames files to temporary names. This commit does not change file contents. --- contract/models/__init__.py | 4 ++-- ...contract_line.py => account_analytic_contract_line_bis.py} | 0 ...c_invoice_line.py => account_analytic_invoice_line_bis.py} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename contract/models/{account_analytic_contract_line.py => account_analytic_contract_line_bis.py} (100%) rename contract/models/{account_analytic_invoice_line.py => account_analytic_invoice_line_bis.py} (100%) diff --git a/contract/models/__init__.py b/contract/models/__init__.py index 3b709b38..94c4df5c 100644 --- a/contract/models/__init__.py +++ b/contract/models/__init__.py @@ -2,7 +2,7 @@ from . import account_analytic_contract from . import account_analytic_account -from . import account_analytic_invoice_line -from . import account_analytic_contract_line +from . import account_analytic_invoice_line_bis +from . import account_analytic_contract_line_bis from . import account_invoice from . import res_partner diff --git a/contract/models/account_analytic_contract_line.py b/contract/models/account_analytic_contract_line_bis.py similarity index 100% rename from contract/models/account_analytic_contract_line.py rename to contract/models/account_analytic_contract_line_bis.py diff --git a/contract/models/account_analytic_invoice_line.py b/contract/models/account_analytic_invoice_line_bis.py similarity index 100% rename from contract/models/account_analytic_invoice_line.py rename to contract/models/account_analytic_invoice_line_bis.py From 31df1b73ec5c0e00ed3b9dbc2219e8d918f3bdc7 Mon Sep 17 00:00:00 2001 From: Dmytro Katyukha Date: Thu, 12 Jul 2018 14:52:10 +0300 Subject: [PATCH 3/4] Rename account_analytic_*_line files In previous commit 'account_analytic_*_line' model files were renamed to temporary names. This commit renames these files to correct names --- contract/models/__init__.py | 4 ++-- ..._invoice_line_bis.py => account_analytic_contract_line.py} | 0 ..._contract_line_bis.py => account_analytic_invoice_line.py} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename contract/models/{account_analytic_invoice_line_bis.py => account_analytic_contract_line.py} (100%) rename contract/models/{account_analytic_contract_line_bis.py => account_analytic_invoice_line.py} (100%) diff --git a/contract/models/__init__.py b/contract/models/__init__.py index 94c4df5c..406cc389 100644 --- a/contract/models/__init__.py +++ b/contract/models/__init__.py @@ -2,7 +2,7 @@ from . import account_analytic_contract from . import account_analytic_account -from . import account_analytic_invoice_line_bis -from . import account_analytic_contract_line_bis +from . import account_analytic_contract_line +from . import account_analytic_invoice_line from . import account_invoice from . import res_partner diff --git a/contract/models/account_analytic_invoice_line_bis.py b/contract/models/account_analytic_contract_line.py similarity index 100% rename from contract/models/account_analytic_invoice_line_bis.py rename to contract/models/account_analytic_contract_line.py diff --git a/contract/models/account_analytic_contract_line_bis.py b/contract/models/account_analytic_invoice_line.py similarity index 100% rename from contract/models/account_analytic_contract_line_bis.py rename to contract/models/account_analytic_invoice_line.py From 4bffe595fc6a91b4ff9f27274f8d24214fe5e9ac Mon Sep 17 00:00:00 2001 From: Dmytro Katyukha Date: Thu, 12 Jul 2018 21:11:28 +0300 Subject: [PATCH 4/4] Update addon versions - contract - contract_variable_quantity --- contract/__manifest__.py | 2 +- contract_variable_quantity/__manifest__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contract/__manifest__.py b/contract/__manifest__.py index ad727d13..37155810 100644 --- a/contract/__manifest__.py +++ b/contract/__manifest__.py @@ -8,7 +8,7 @@ { 'name': 'Contracts Management - Recurring', - 'version': '11.0.2.1.0', + 'version': '11.0.3.0.0', 'category': 'Contract Management', 'license': 'AGPL-3', 'author': "OpenERP SA, " diff --git a/contract_variable_quantity/__manifest__.py b/contract_variable_quantity/__manifest__.py index 325b64a4..c28d7de4 100644 --- a/contract_variable_quantity/__manifest__.py +++ b/contract_variable_quantity/__manifest__.py @@ -4,7 +4,7 @@ { 'name': 'Variable quantity in contract recurrent invoicing', - 'version': '11.0.1.2.1', + 'version': '11.0.1.3.0', 'category': 'Contract Management', 'license': 'AGPL-3', 'author': "Tecnativa,"