summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2019-12-16 10:40:05 +0000
committerSimon Lejeune <sle@openerp.com>2019-12-21 10:43:00 +0000
commit4f0b6d6ce51bf7e2bf403e80425a8b2afe439573 (patch)
tree9e7cadeaa381ef12f8bdeceeb2869b70054253a7 /addons
parent26fac9a8346b6b78e89645978bd66308ef08c587 (diff)
[FIX] stock: wrong security rule
rev[0] aimed to fix an intercompany reservation issue by allowing the intercompany moves to be seen, however the new domain was too soft and also allows the visibility of any moves going to a location without company, for example now outgoing moves to customer from all companies are visible. We strengthen the domain to only allow intercompany moves, ie we add the transit constraint in the domain. We also fix the same issue for the move line model (see [1]) Now that this one is fixed, the next move is automatically reserved during _action_done. This didn't work either, so we carefully sudo and force_company on the destination move. [0] 3c4bb080c3ab71b63cf90a6b49ffebb3ea1e5545 [1] f9461c7096a65565a05136a4c6c42ddfa6881926 task-2157248 closes odoo/odoo#42270 X-original-commit: 9a237d1af79519665d0895a30c9ce55a1d835918 Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/stock/models/stock_move.py7
-rw-r--r--addons/stock/security/stock_security.xml4
2 files changed, 8 insertions, 3 deletions
diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py
index 96a3af94ab8..2655a5381a7 100644
--- a/addons/stock/models/stock_move.py
+++ b/addons/stock/models/stock_move.py
@@ -1358,7 +1358,12 @@ class StockMove(models.Model):
raise UserError(_('You cannot move the same package content more than once in the same transfer or split the same package into two location.'))
picking = moves_todo.mapped('picking_id')
moves_todo.write({'state': 'done', 'date': fields.Datetime.now()})
- moves_todo.mapped('move_dest_ids')._action_assign()
+
+ move_dests_per_company = defaultdict(lambda: self.env['stock.move'])
+ for move_dest in moves_todo.move_dest_ids:
+ move_dests_per_company[move_dest.company_id.id] |= move_dest
+ for company_id, move_dests in move_dests_per_company.items():
+ move_dests.sudo().with_company(company_id)._action_assign()
# We don't want to create back order for scrap moves
# Replace by a kwarg in master
diff --git a/addons/stock/security/stock_security.xml b/addons/stock/security/stock_security.xml
index 3ffaa1cc9ab..bbf0a2714f5 100644
--- a/addons/stock/security/stock_security.xml
+++ b/addons/stock/security/stock_security.xml
@@ -116,14 +116,14 @@
<field name="name">stock_move multi-company</field>
<field name="model_id" search="[('model','=','stock.move')]" model="ir.model"/>
<field name="global" eval="True"/>
- <field name="domain_force">['|', ('company_id', 'in', company_ids), ('location_dest_id.company_id', '=', False)]</field>
+ <field name="domain_force">['|', ('company_id', 'in', company_ids), '&amp;', ('location_dest_id.company_id', '=', False), ('location_dest_id.usage', '=', 'transit')]</field>
</record>
<record model="ir.rule" id="stock_move_line_rule">
<field name="name">stock_move_line multi-company</field>
<field name="model_id" search="[('model','=','stock.move.line')]" model="ir.model"/>
<field name="global" eval="True"/>
- <field name="domain_force">['|','|',('company_id','=',False),('company_id', 'in', company_ids),('location_dest_id.company_id', '=', False)]</field>
+ <field name="domain_force">['|','|',('company_id','=',False),('company_id', 'in', company_ids),'&amp;',('location_dest_id.company_id', '=', False), ('location_dest_id.usage', '=', 'transit')]</field>
</record>
<record model="ir.rule" id="stock_quant_rule">