From 373b289cfa3ccda1660927838fb8fa2047154984 Mon Sep 17 00:00:00 2001 From: Dmytro Katyukha Date: Wed, 27 Jun 2018 00:40:12 +0300 Subject: [PATCH] [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 +++++---- 2 files changed, 10 insertions(+), 10 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', )