[FIX] purchase_*: ensure properties are read with the correct company.
This commit is contained in:
@@ -15,6 +15,7 @@ class PurchaseOrder(models.Model):
|
||||
if not self.requisition_id:
|
||||
return
|
||||
|
||||
self = self.with_company(self.company_id)
|
||||
requisition = self.requisition_id
|
||||
if self.partner_id:
|
||||
partner = self.partner_id
|
||||
|
||||
@@ -75,6 +75,7 @@ class PurchaseRequisition(models.Model):
|
||||
|
||||
@api.onchange('vendor_id')
|
||||
def _onchange_vendor(self):
|
||||
self = self.with_company(self.company_id)
|
||||
if not self.vendor_id:
|
||||
self.currency_id = self.env.company.currency_id.id
|
||||
else:
|
||||
@@ -84,6 +85,7 @@ class PurchaseRequisition(models.Model):
|
||||
('vendor_id', '=', self.vendor_id.id),
|
||||
('state', '=', 'ongoing'),
|
||||
('type_id.quantity_copy', '=', 'none'),
|
||||
('company_id', '=', self.company_id),
|
||||
])
|
||||
if any(requisitions):
|
||||
title = _("Warning for %s") % self.vendor_id.name
|
||||
|
||||
@@ -40,6 +40,7 @@ class AccountMove(models.Model):
|
||||
if move.move_type not in ('in_invoice', 'in_refund', 'in_receipt') or not move.company_id.anglo_saxon_accounting:
|
||||
continue
|
||||
|
||||
move = move.with_company(move.company_id)
|
||||
for line in move.invoice_line_ids.filtered(lambda line: line.product_id.type == 'product' and line.product_id.valuation == 'real_time'):
|
||||
|
||||
# Filter out lines being not eligible for price difference.
|
||||
|
||||
@@ -187,7 +187,6 @@ class PurchaseOrder(models.Model):
|
||||
picking_type = self.env['stock.picking.type'].search([('code', '=', 'incoming'), ('warehouse_id', '=', False)])
|
||||
return picking_type[:1]
|
||||
|
||||
@api.model
|
||||
def _prepare_picking(self):
|
||||
if not self.group_id:
|
||||
self.group_id = self.group_id.create({
|
||||
@@ -210,6 +209,7 @@ class PurchaseOrder(models.Model):
|
||||
def _create_picking(self):
|
||||
StockPicking = self.env['stock.picking']
|
||||
for order in self:
|
||||
order = order.with_company(order.company_id)
|
||||
if any([ptype in ['product', 'consu'] for ptype in order.order_line.mapped('product_id.type')]):
|
||||
pickings = order.picking_ids.filtered(lambda x: x.state not in ('done', 'cancel'))
|
||||
if not pickings:
|
||||
|
||||
Reference in New Issue
Block a user