[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
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user