[FIX] stock: move company initial setup logic in model

Followup of 4e71bd5caf
This commit is contained in:
Christophe Simonis
2018-05-23 17:07:28 +02:00
parent 73e213edef
commit a496ca981c
2 changed files with 6 additions and 7 deletions
-7
View File
@@ -1,6 +1,3 @@
-
!python {model: res.partner, id: base.main_partner}: |
main_warehouse = self.env['stock.warehouse'].browse(ref('warehouse0'))
-
!python {model: ir.model.data, id: False}: |
main_warehouse = self.env['stock.warehouse'].browse(ref('warehouse0'))
@@ -28,7 +25,3 @@
companies = self.search([('internal_transit_location_id', '=', False)])
for company in companies:
company.create_transit_location()
internal_transit = company.internal_transit_location_id.id
warehouses = self.env['stock.warehouse'].search([('partner_id', '=', company.partner_id.id)])
warehouses.mapped('partner_id').with_context(force_company=company.id).write({'property_stock_customer': internal_transit, 'property_stock_supplier': internal_transit})
+6
View File
@@ -28,6 +28,12 @@ class Company(models.Model):
location.sudo().write({'company_id': self.id})
self.write({'internal_transit_location_id': location.id})
warehouses = self.env['stock.warehouse'].search([('partner_id', '=', self.partner_id.id)])
warehouses.mapped('partner_id').with_context(force_company=self.id).write({
'property_stock_customer': location.id,
'property_stock_supplier': location.id,
})
@api.model
def create(self, vals):
company = super(Company, self).create(vals)