[FIX] repair: ensure the pricelist is in the right company
Default and onchange fallbacks don't consider the current company when searching for a pricelist. Forward-port of #46429 closes odoo/odoo#49650 X-original-commit: 812af92080648bdb7f7bb0e4e6aef55c6dc4b9d4 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com> Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
@@ -76,7 +76,7 @@ class Repair(models.Model):
|
||||
copy=True, readonly=True, states={'draft': [('readonly', False)]})
|
||||
pricelist_id = fields.Many2one(
|
||||
'product.pricelist', 'Pricelist',
|
||||
default=lambda self: self.env['product.pricelist'].search([], limit=1).id,
|
||||
default=lambda self: self.env['product.pricelist'].search([('company_id', 'in', [self.env.company.id, False])], limit=1).id,
|
||||
help='Pricelist of the selected partner.', check_company=True)
|
||||
partner_invoice_id = fields.Many2one('res.partner', 'Invoicing Address', check_company=True)
|
||||
invoice_method = fields.Selection([
|
||||
@@ -177,7 +177,9 @@ class Repair(models.Model):
|
||||
if not self.partner_id:
|
||||
self.address_id = False
|
||||
self.partner_invoice_id = False
|
||||
self.pricelist_id = self.env['product.pricelist'].search([], limit=1).id
|
||||
self.pricelist_id = self.env['product.pricelist'].search([
|
||||
('company_id', 'in', [self.env.company.id, False]),
|
||||
], limit=1)
|
||||
else:
|
||||
addresses = self.partner_id.address_get(['delivery', 'invoice', 'contact'])
|
||||
self.address_id = addresses['delivery'] or addresses['contact']
|
||||
|
||||
Reference in New Issue
Block a user