stock_valuation_xlsx: fix multicompany issues

fix: ref('stock.warehouse0') may belong to a different
company
add: allow to select stock parent location like physical
in order to export all the wh at once
This commit is contained in:
hparfr
2023-06-15 09:31:33 +02:00
parent 2863de99f4
commit e698746dd1
2 changed files with 6 additions and 6 deletions

View File

@@ -27,10 +27,10 @@ class StockValuationXlsx(models.TransientModel):
required=True) required=True)
warehouse_id = fields.Many2one( warehouse_id = fields.Many2one(
'stock.warehouse', string='Warehouse', check_company=True, 'stock.warehouse', string='Warehouse', check_company=True,
domain="[('company_id', '=', company_id)]") domain="[('company_id', 'in', [False, company_id])]")
location_id = fields.Many2one( location_id = fields.Many2one(
'stock.location', string='Root Stock Location', required=True, 'stock.location', string='Root Stock Location', required=True,
domain="[('usage', 'in', ('view', 'internal')), ('company_id', '=', company_id)]", domain="[('usage', 'in', ('view', 'internal')), ('company_id', 'in', [False, company_id])]",
default=lambda self: self._default_location(), check_company=True, default=lambda self: self._default_location(), check_company=True,
help="The childen locations of the selected locations will " help="The childen locations of the selected locations will "
"be taken in the valuation.") "be taken in the valuation.")
@@ -75,7 +75,7 @@ class StockValuationXlsx(models.TransientModel):
@api.model @api.model
def _default_location(self): def _default_location(self):
wh = self.env.ref('stock.warehouse0') wh = self.env["stock.warehouse"].search([], limit=1)
return wh.lot_stock_id return wh.lot_stock_id
@api.onchange('warehouse_id') @api.onchange('warehouse_id')

View File

@@ -25,10 +25,10 @@ class StockVariationXlsx(models.TransientModel):
required=True) required=True)
warehouse_id = fields.Many2one( warehouse_id = fields.Many2one(
'stock.warehouse', string='Warehouse', check_company=True, 'stock.warehouse', string='Warehouse', check_company=True,
domain="[('company_id', '=', company_id)]") domain="[('company_id', 'in', [False, company_id])]")
location_id = fields.Many2one( location_id = fields.Many2one(
'stock.location', string='Root Stock Location', required=True, 'stock.location', string='Root Stock Location', required=True,
domain="[('usage', 'in', ('view', 'internal')), ('company_id', '=', company_id)]", domain="[('usage', 'in', ('view', 'internal')), ('company_id', 'in', [False, company_id])]",
default=lambda self: self._default_location(), check_company=True, default=lambda self: self._default_location(), check_company=True,
help="The childen locations of the selected locations will " help="The childen locations of the selected locations will "
"be taken in the valuation.") "be taken in the valuation.")
@@ -58,7 +58,7 @@ class StockVariationXlsx(models.TransientModel):
@api.model @api.model
def _default_location(self): def _default_location(self):
wh = self.env.ref('stock.warehouse0') wh = self.env["stock.warehouse"].search([], limit=1)
return wh.lot_stock_id return wh.lot_stock_id
@api.onchange('warehouse_id') @api.onchange('warehouse_id')