stdout: stderr: 13:41:03.985365 git.c:344 trace: built-in: git cherry-pick 20858c2a8805d9ec08edb98b090badf6c73fc342 error: Cherry-picking is not possible because you have unmerged files. hint: Fix them up in the work tree, and then use 'git add/rm <file>' hint: as appropriate to mark resolution and make a commit. fatal: cherry-pick failed ---------- status: closes odoo/odoo#79933 Signed-off-by: William Henrotin (whe) <whe@odoo.com>
35 lines
1.5 KiB
Python
35 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import models, _
|
|
from odoo.exceptions import UserError
|
|
|
|
|
|
class PurchaseOrder(models.Model):
|
|
_inherit = 'purchase.order'
|
|
|
|
def _get_destination_location(self):
|
|
self.ensure_one()
|
|
if not self.dest_address_id:
|
|
return super()._get_destination_location()
|
|
|
|
mrp_production_ids = self._get_mrp_productions(remove_archived_picking_types=False)
|
|
if mrp_production_ids:
|
|
if self.dest_address_id in mrp_production_ids.bom_id.subcontractor_ids:
|
|
return self.dest_address_id.property_stock_subcontractor.id
|
|
elif self.sale_order_count:
|
|
return super()._get_destination_location()
|
|
|
|
in_bom_products = False
|
|
not_in_bom_products = False
|
|
for order_line in self.order_line:
|
|
if any(bom_line.bom_id.type == 'subcontract' and self.dest_address_id in bom_line.bom_id.subcontractor_ids for bom_line in order_line.product_id.bom_line_ids.filtered(lambda line: line.company_id == self.company_id)):
|
|
in_bom_products = True
|
|
else:
|
|
not_in_bom_products = True
|
|
if in_bom_products and not_in_bom_products:
|
|
raise UserError(_("It appears some components in this RFQ are not meant for subcontracting. Please create a separate order for these."))
|
|
elif in_bom_products:
|
|
return self.dest_address_id.property_stock_subcontractor.id
|
|
return super()._get_destination_location()
|