[IMP] mrp_subcontracting: filter on partner and product
Allow to easily find product and partners related to subcontracting closes odoo/odoo#43046 Task: 2158126 Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
'views/stock_move_views.xml',
|
||||
'views/stock_picking_views.xml',
|
||||
'views/supplier_info_views.xml',
|
||||
'views/product_views.xml',
|
||||
'wizard/stock_picking_return_views.xml',
|
||||
],
|
||||
'demo': [
|
||||
|
||||
@@ -11,3 +11,15 @@ class ResPartner(models.Model):
|
||||
'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)]
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="mrp_subcontracting_product_template_search_view" model="ir.ui.view">
|
||||
<field name="name">mrp.subcontracting.product.template.search</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_search_view" />
|
||||
<field name="groups_id" eval="[(4, ref('mrp.group_mrp_user'))]"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//filter[@name='filter_to_purchase']" position="after">
|
||||
<filter string="Can be Subcontracted" name="filter_can_be_subcontracted" domain="[('bom_ids.type', '=', 'subcontract')]" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -10,4 +10,15 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_partner_mrp_subcontracting_filter" model="ir.ui.view">
|
||||
<field name="name">res.partner.select.inherit</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="base.view_res_partner_filter" />
|
||||
<field name="groups_id" eval="[(4, ref('mrp.group_mrp_user'))]"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//filter[@name='inactive']" position="before">
|
||||
<filter string="Subcontractors" name="type_subcontractors" domain="[('is_subcontractor', '=', True)]" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user