From f6ebe6e9c7d47929cccfafb952aeec95191e285c Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Tue, 28 Nov 2017 12:19:57 -0800 Subject: [PATCH] [FIX+IMP] contract: Real fix to company_id missing + improvements * company_id was empty because an onchange, not inheritance nor visibility * Added multi-company group to company_id fields * Added multi-company access rule to contract templates * Fix double %% in XML dates that was causing an error * When creating a contract, recurring_invoices is set by default --- contract/__manifest__.py | 3 ++- contract/models/account_analytic_account.py | 6 ++---- contract/security/contract_security.xml | 10 ++++++++++ contract/views/account_analytic_account_view.xml | 7 ++++--- contract/views/account_analytic_contract_view.xml | 2 +- 5 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 contract/security/contract_security.xml diff --git a/contract/__manifest__.py b/contract/__manifest__.py index b7e57492..ddf7c225 100644 --- a/contract/__manifest__.py +++ b/contract/__manifest__.py @@ -9,7 +9,7 @@ { 'name': 'Contracts Management - Recurring', - 'version': '10.0.3.1.0', + 'version': '10.0.3.2.0', 'category': 'Contract Management', 'license': 'AGPL-3', 'author': "OpenERP SA, " @@ -20,6 +20,7 @@ 'depends': ['base', 'account', 'analytic'], 'data': [ 'security/ir.model.access.csv', + 'security/contract_security.xml', 'report/report_contract.xml', 'report/contract_views.xml', 'data/contract_cron.xml', diff --git a/contract/models/account_analytic_account.py b/contract/models/account_analytic_account.py index 89afa911..dbcaa0f8 100644 --- a/contract/models/account_analytic_account.py +++ b/contract/models/account_analytic_account.py @@ -61,15 +61,13 @@ class AccountAnalyticAccount(models.Model): deletion ensures that any errant lines that are created are also deleted. """ - contract = self.contract_template_id - + if not contract: + return for field_name, field in contract._fields.iteritems(): - if field.name == 'recurring_invoice_line_ids': lines = self._convert_contract_lines(contract) self.recurring_invoice_line_ids = lines - elif not any(( field.compute, field.related, field.automatic, field.readonly, field.company_dependent, diff --git a/contract/security/contract_security.xml b/contract/security/contract_security.xml new file mode 100644 index 00000000..3884e6ef --- /dev/null +++ b/contract/security/contract_security.xml @@ -0,0 +1,10 @@ + + + + Contract template multi-company + + + ['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])] + + + diff --git a/contract/views/account_analytic_account_view.xml b/contract/views/account_analytic_account_view.xml index c2fc586a..af2ff27e 100644 --- a/contract/views/account_analytic_account_view.xml +++ b/contract/views/account_analytic_account_view.xml @@ -38,6 +38,7 @@ +