From 438e1c1daf5bc4eb212f78b87f277fff8e8a0ceb Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 8 Apr 2013 01:50:13 +0200 Subject: [PATCH] [FIX] res.partner: Hide commercial-related fields on contacts form + autosync them from parent company Fixes handling of accounting/invoicing-related fields on partners that are not "commercial entities" (either marked as "is_company" or parentless). The corresponding fields are also hidden from form views on these partners and replaced by a short sentence and a link to edit the "master fields" on the commercial entity. This corresponds to part B of the solution described on bug 1160365. lp bug: https://launchpad.net/bugs/1160365 fixed bzr revid: odo@openerp.com-20130407235013-j3tv4uxy46eej43i --- addons/account/partner.py | 5 +++++ addons/account/partner_view.xml | 7 ++++++- addons/base_vat/base_vat.py | 3 +++ addons/l10n_be_invoice_bba/partner.py | 5 +++++ addons/l10n_ro/res_partner.py | 4 ++++ addons/product/partner.py | 3 +++ addons/product/partner_view.xml | 5 ++++- addons/purchase/partner.py | 3 +++ addons/sale_journal/sale_journal.py | 4 ++++ addons/sale_journal/sale_journal_view.xml | 2 +- 10 files changed, 38 insertions(+), 3 deletions(-) diff --git a/addons/account/partner.py b/addons/account/partner.py index ae8d2fc1871..4914a17dd2b 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -236,6 +236,11 @@ class res_partner(osv.osv): 'last_reconciliation_date': fields.datetime('Latest Full Reconciliation Date', help='Date on which the partner accounting entries were fully reconciled last time. It differs from the last date where a reconciliation has been made for this partner, as here we depict the fact that nothing more was to be reconciled at this date. This can be achieved in 2 different ways: either the last unreconciled debit/credit entry of this partner was reconciled, either the user pressed the button "Nothing more to reconcile" during the manual reconciliation process.') } + def _commercial_fields(self, cr, uid, context=None): + return super(res_partner, self)._commercial_fields(cr, uid, context=context) + \ + ['debit_limit', 'property_account_payable', 'property_account_receivable', 'property_account_position', + 'property_payment_term', 'property_supplier_payment_term', 'last_reconciliation_date'] + res_partner() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/partner_view.xml b/addons/account/partner_view.xml index 1267e20165b..abded67f6ab 100644 --- a/addons/account/partner_view.xml +++ b/addons/account/partner_view.xml @@ -73,7 +73,7 @@ - + @@ -103,6 +103,11 @@ + +
+

Accounting-related settings are managed on

+
diff --git a/addons/base_vat/base_vat.py b/addons/base_vat/base_vat.py index 616333e3b47..3366101c7c7 100644 --- a/addons/base_vat/base_vat.py +++ b/addons/base_vat/base_vat.py @@ -134,6 +134,9 @@ class res_partner(osv.osv): 'vat_subjected': fields.boolean('VAT Legal Statement', help="Check this box if the partner is subjected to the VAT. It will be used for the VAT legal statement.") } + def _commercial_fields(self, cr, uid, context=None): + return super(res_partner, self)._commercial_fields(cr, uid, context=context) + ['vat_subjected'] + def _construct_constraint_msg(self, cr, uid, ids, context=None): def default_vat_check(cn, vn): # by default, a VAT number is valid if: diff --git a/addons/l10n_be_invoice_bba/partner.py b/addons/l10n_be_invoice_bba/partner.py index 9e0eec10713..df68268bf43 100644 --- a/addons/l10n_be_invoice_bba/partner.py +++ b/addons/l10n_be_invoice_bba/partner.py @@ -44,6 +44,11 @@ class res_partner(osv.osv): help='Select Algorithm to generate the Structured Communication on Outgoing Invoices.' ), } + def _commercial_fields(self, cr, uid, context=None): + return super(res_partner, self)._commercial_fields(cr, uid, context=context) + \ + ['out_inv_comm_type', 'out_inv_comm_algorithm'] + + _default = { 'out_inv_comm_type': 'none', } diff --git a/addons/l10n_ro/res_partner.py b/addons/l10n_ro/res_partner.py index 1cfe7390a77..95867f8e883 100755 --- a/addons/l10n_ro/res_partner.py +++ b/addons/l10n_ro/res_partner.py @@ -32,6 +32,10 @@ class res_partner(osv.osv): ('vat_uniq', 'unique (vat)', 'The vat of the partner must be unique !'), ('nrc_uniq', 'unique (nrc)', 'The code of the partner must be unique !') ] + + def _commercial_fields(self, cr, uid, context=None): + return super(res_partner, self)._commercial_fields(cr, uid, context=context) + ['nrc'] + res_partner() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/product/partner.py b/addons/product/partner.py index 1d11e909346..4a291a8ddd3 100644 --- a/addons/product/partner.py +++ b/addons/product/partner.py @@ -36,6 +36,9 @@ class res_partner(osv.osv): help="This pricelist will be used, instead of the default one, for sales to the current partner"), } + def _commercial_fields(self, cr, uid, context=None): + return super(res_partner, self)._commercial_fields(cr, uid, context=context) + ['property_product_pricelist'] + res_partner() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/product/partner_view.xml b/addons/product/partner_view.xml index acb087533ac..5117da6044e 100644 --- a/addons/product/partner_view.xml +++ b/addons/product/partner_view.xml @@ -8,9 +8,12 @@ - + +
+

Pricelists are managed on

diff --git a/addons/purchase/partner.py b/addons/purchase/partner.py index 56eaf288fe6..e05f6b9c9c6 100644 --- a/addons/purchase/partner.py +++ b/addons/purchase/partner.py @@ -43,6 +43,9 @@ class res_partner(osv.osv): super(res_partner, self).copy(cr, uid, id, default=default, context=context) + def _commercial_fields(self, cr, uid, context=None): + return super(res_partner, self)._commercial_fields(cr, uid, context=context) + ['property_product_pricelist_purchase'] + _columns = { 'property_product_pricelist_purchase': fields.property( 'product.pricelist', diff --git a/addons/sale_journal/sale_journal.py b/addons/sale_journal/sale_journal.py index 8463ab3f3bd..cb33d7e2334 100644 --- a/addons/sale_journal/sale_journal.py +++ b/addons/sale_journal/sale_journal.py @@ -52,6 +52,10 @@ class res_partner(osv.osv): group_name = "Accounting Properties", help = "This invoicing type will be used, by default, to invoice the current partner."), } + + def _commercial_fields(self, cr, uid, context=None): + return super(res_partner, self)._commercial_fields(cr, uid, context=context) + ['property_invoice_type'] + res_partner() class picking(osv.osv): diff --git a/addons/sale_journal/sale_journal_view.xml b/addons/sale_journal/sale_journal_view.xml index bcd83b5be84..9d41103252e 100644 --- a/addons/sale_journal/sale_journal_view.xml +++ b/addons/sale_journal/sale_journal_view.xml @@ -146,7 +146,7 @@ - +