From 8b55cdd7afbdd6beec40de20061b3606d7ea421d Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Wed, 3 Jul 2019 16:59:56 +0000 Subject: [PATCH] [FIX] account, portal, sale, website_sale: get correct company_name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes multiple issues regarding the /shop/address and /my/account forms where both are displaying `vat` and `company_name` fields. 1. For a company's child partner, the `company_name` was empty instead of showing its company name (the name of its parent_id which is the commercial entity). 2. It was possible for a child partner to edit its `vat` (which is a field synced from parent to children, but only parent should be able to edit it as it is the commercial entity, see 4a1bc45934efd and 98b1fffd4e). 3. Company name now share the exact same condition than the vat field in order to be editable (as it should have been). It was possible to edit vat but not company name on /my/account. Steps to reproduce the bug: - Create a company contact CO with a VAT number - Create a contact C in CO with portal access - Log with C and go to the shop - In the checkout, try to edit the address details opw-2007368 closes odoo/odoo#34564 Signed-off-by: Jérémy Kersten (jke) --- addons/account/models/partner.py | 1 + addons/portal/models/res_partner.py | 5 ++++- addons/portal/views/portal_templates.xml | 7 +++++-- addons/sale/models/res_partner.py | 1 + addons/website_sale/views/templates.xml | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py index db91c34a07c..7a6e334b939 100644 --- a/addons/account/models/partner.py +++ b/addons/account/models/partner.py @@ -451,6 +451,7 @@ class ResPartner(models.Model): return {'domain': {'property_account_position_id': [('company_id', 'in', [company.id, False])]}} def can_edit_vat(self): + ''' Can't edit `vat` if there is (non draft) issued invoices. ''' can_edit_vat = super(ResPartner, self).can_edit_vat() if not can_edit_vat: return can_edit_vat diff --git a/addons/portal/models/res_partner.py b/addons/portal/models/res_partner.py index 4c8d02943c5..064fa2ff04e 100644 --- a/addons/portal/models/res_partner.py +++ b/addons/portal/models/res_partner.py @@ -8,4 +8,7 @@ class ResPartner(models.Model): _inherit = 'res.partner' def can_edit_vat(self): - return True + ''' `vat` is a commercial field, synced between the parent (commercial + entity) and the children. Only the commercial entity should be able to + edit it (as in backend). ''' + return not self.parent_id diff --git a/addons/portal/views/portal_templates.xml b/addons/portal/views/portal_templates.xml index 4059e2641fb..5783a1c24f8 100644 --- a/addons/portal/views/portal_templates.xml +++ b/addons/portal/views/portal_templates.xml @@ -378,8 +378,11 @@
-

- + +

+

diff --git a/addons/sale/models/res_partner.py b/addons/sale/models/res_partner.py index a1f60defb2d..fac5165f55f 100644 --- a/addons/sale/models/res_partner.py +++ b/addons/sale/models/res_partner.py @@ -30,6 +30,7 @@ class ResPartner(models.Model): partner = partner.parent_id def can_edit_vat(self): + ''' Can't edit `vat` if there is (non draft) issued SO. ''' can_edit_vat = super(ResPartner, self).can_edit_vat() if not can_edit_vat: return can_edit_vat diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml index 5b89ad4982b..47dd679ba31 100644 --- a/addons/website_sale/views/templates.xml +++ b/addons/website_sale/views/templates.xml @@ -1286,7 +1286,7 @@
- +