From affce2c49c1331b655d339d2f19fac0f66f5f13f Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 4 Nov 2015 14:45:37 +0100 Subject: [PATCH] [FIX] account, website_sale: do not set fpos on res.partner automatically When a partner is created, the fiscal position is set automatically if possible. This is not correct, the fiscal position should only be set automatically on a SO, based on the delivery address. Here is a scenario explaining the reason: - Create 2 fiscal positions, one in US and one in Canada. Both fiscal positions apply automatically depending on the country. - As an non-logged user, go in the web shop - Buy a product - At the checkout phase, the Billing Information are in US, but the Shipping Information in Canada. - The fiscal position which will apply will be US, while you expect it to be Canada The reason is that the fical position which applies is the one on the parent partner (US in this case), since all children partners must have the same accounting data. With this fix, we simply remove the automatic setting of the fiscal position on the partner. opw-653072 --- addons/account/models/partner.py | 12 ------------ addons/website_sale/controllers/main.py | 3 --- 2 files changed, 15 deletions(-) diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py index e789c36080b..2b861562eeb 100644 --- a/addons/account/models/partner.py +++ b/addons/account/models/partner.py @@ -228,18 +228,6 @@ class ResPartner(models.Model): _inherit = 'res.partner' _description = 'Partner' - @api.multi - def onchange_state(self, state_id): - res = super(ResPartner, self).onchange_state(state_id=state_id) - res['value']['property_account_position_id'] = self.env['account.fiscal.position']._get_fpos_by_region( - country_id=self.env.context.get('country_id'), state_id=state_id, zipcode=self.env.context.get('zip')) - return res - - @api.onchange('country_id', 'zip') - def _onchange_country_id(self): - self.property_account_position_id = self.env['account.fiscal.position']._get_fpos_by_region( - country_id=self.country_id.id, state_id=self.state_id.id, zipcode=self.zip) - @api.multi def _credit_debit_get(self): tables, where_clause, where_params = self.env['account.move.line']._query_get() diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 8264cc4ac01..680be96df9d 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -615,9 +615,6 @@ class website_sale(http.Controller): partner_id = order.partner_id.id # save partner informations - if billing_info.get('country_id'): - billing_info['property_account_position_id'] = request.registry['account.fiscal.position']._get_fpos_by_region( - cr, SUPERUSER_ID, billing_info['country_id'], billing_info.get('state_id') or False, billing_info.get('zip'), billing_info.get('vat') and True or False) if partner_id and request.website.partner_id.id != partner_id: orm_partner.write(cr, SUPERUSER_ID, [partner_id], billing_info, context=context) else: