[FIX] sale: default company on SO
In multi-company:
- Create 2 companies A and B
- Set the superuser on company B
- Set the website on company A
- Define company specific sequences for SO (e.g. SOA and SOB)
When a SO is generated from the eCommerce, it is defined on company A
(thanks to 8a1b55a), but the sequence is from company B.
opw-744561
This commit is contained in:
+4
-1
@@ -225,7 +225,10 @@ class SaleOrder(models.Model):
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if vals.get('name', _('New')) == _('New'):
|
||||
vals['name'] = self.env['ir.sequence'].next_by_code('sale.order') or _('New')
|
||||
if 'company_id' in vals:
|
||||
vals['name'] = self.env['ir.sequence'].with_context(force_company=vals['company_id']).next_by_code('sale.order') or _('New')
|
||||
else:
|
||||
vals['name'] = self.env['ir.sequence'].next_by_code('sale.order') or _('New')
|
||||
|
||||
# Makes sure partner_invoice_id', 'partner_shipping_id' and 'pricelist_id' are defined
|
||||
if any(f not in vals for f in ['partner_invoice_id', 'partner_shipping_id', 'pricelist_id']):
|
||||
|
||||
Reference in New Issue
Block a user