Debian Codegraph @

addons/mrp_subcontracting_dropshipping/models/stock_rule.py

raw symbols SCIP
1 # -*- encoding: utf-8 -*-
2 # Part of Odoo. See LICENSE file for full copyright and licensing details.
3
4 from odoo import models
5
6
7 class StockRule(models.Model):
8 _inherit = 'stock.rule'
9
10 def _prepare_purchase_order(self, company_id, origins, values):
11 if not values[0].get('partner_id') \
12 and (company_id.subcontracting_location_id.parent_path in self.location_dest_id.parent_path
13 or self.location_dest_id.is_subcontract()):
14 move = values[0].get('move_dest_ids')
15 if move and move.raw_material_production_id.subcontractor_id:
16 values[0]['partner_id'] = move.raw_material_production_id.subcontractor_id.id
17 return super()._prepare_purchase_order(company_id, origins, values)
18
19 def _make_po_get_domain(self, company_id, values, partner):
20 domain = super()._make_po_get_domain(company_id, values, partner)
21 if self.location_src_id.usage == 'supplier' and self.location_dest_id.is_subcontract() and values.get('partner_id', False):
22 domain += (('dest_address_id', '=', values.get('partner_id')),)
23 return domain