summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorWilliam Henrotin <whe@odoo.com>2019-04-16 13:38:59 +0000
committerWilliam Henrotin <whe@odoo.com>2019-04-16 13:38:59 +0000
commit2b63b7e8edfd052682bb01be7a2b4f66c1f6e8fb (patch)
treef66e967b1ba8b3727744bd88cbce8d87ba551ea2 /addons
parent3992b01de1420be0f57dac6a387e5005c329b37a (diff)
[FIX] stock: company_id on stock.move.line
Commit 240d191ba302e6df200f7c91898c83c08ced758a introduced the field company_id on model stock.move.line and a python constraint that check if the company is the same on the move line and on the related move. In order to avoid performance issue, this commit replace the constraint by a 'related' parameter on the company field. As the company_id is not editable we suppose this change will not introduced unwanted errors Task : 1970012 closes odoo/odoo#32738 Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/stock/models/stock_move_line.py8
-rw-r--r--addons/stock/security/stock_security.xml2
2 files changed, 2 insertions, 8 deletions
diff --git a/addons/stock/models/stock_move_line.py b/addons/stock/models/stock_move_line.py
index 0334981c217..68e5f3c3aad 100644
--- a/addons/stock/models/stock_move_line.py
+++ b/addons/stock/models/stock_move_line.py
@@ -21,7 +21,7 @@ class StockMoveLine(models.Model):
move_id = fields.Many2one(
'stock.move', 'Stock Move',
help="Change to a better name", index=True)
- company_id = fields.Many2one('res.company', string='Company', default=lambda self: self.env['res.users']._get_company(), readonly=True)
+ company_id = fields.Many2one('res.company', string='Company', related='move_id.company_id', store=True, readonly=True)
product_id = fields.Many2one('product.product', 'Product', ondelete="cascade")
product_uom_id = fields.Many2one('uom.uom', 'Unit of Measure', required=True)
product_qty = fields.Float(
@@ -74,12 +74,6 @@ class StockMoveLine(models.Model):
if line.lot_id and line.product_id != line.lot_id.product_id:
raise ValidationError(_('This lot %s is incompatible with this product %s' % (line.lot_id.name, line.product_id.display_name)))
- @api.constrains('company_id', 'move_id')
- def _check_same_company_id(self):
- for line in self:
- if line.move_id and line.move_id.company_id != line.company_id:
- raise ValidationError(_('The move line a a different company than its move'))
-
@api.one
def _set_product_qty(self):
""" The meaning of product_qty field changed lately and is now a functional field computing the quantity
diff --git a/addons/stock/security/stock_security.xml b/addons/stock/security/stock_security.xml
index e33e665842a..87c63386ca7 100644
--- a/addons/stock/security/stock_security.xml
+++ b/addons/stock/security/stock_security.xml
@@ -101,7 +101,7 @@
<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','child_of',[user.company_id.id])]</field>
+ <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
</record>
<record model="ir.rule" id="stock_quant_rule">