diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/mrp_subcontracting/models/res_partner.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/mrp_subcontracting/models/res_partner.py')
| -rw-r--r-- | addons/mrp_subcontracting/models/res_partner.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/addons/mrp_subcontracting/models/res_partner.py b/addons/mrp_subcontracting/models/res_partner.py new file mode 100644 index 00000000..67756a80 --- /dev/null +++ b/addons/mrp_subcontracting/models/res_partner.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + property_stock_subcontractor = fields.Many2one( + 'stock.location', string="Subcontractor Location", company_dependent=True, + help="The stock location used as source and destination when sending\ + goods to this contact during a subcontracting process.") + is_subcontractor = fields.Boolean( + string="Subcontractor", store=False, search="_search_is_subcontractor") + + def _search_is_subcontractor(self, operator, value): + assert operator in ('=', '!=', '<>') and value in (True, False), 'Operation not supported' + subcontractor_ids = self.env['mrp.bom'].search( + [('type', '=', 'subcontract')]).subcontractor_ids.ids + if (operator == '=' and value is True) or (operator in ('<>', '!=') and value is False): + search_operator = 'in' + else: + search_operator = 'not in' + return [('id', search_operator, subcontractor_ids)] |
