[IMP] stock,mrp_subcontracting: rearange quants filters
Task : 2555118 Part-of: odoo/odoo#74715
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
'views/res_partner_views.xml',
|
||||
'views/stock_warehouse_views.xml',
|
||||
'views/stock_move_views.xml',
|
||||
'views/stock_quant_views.xml',
|
||||
'views/stock_picking_views.xml',
|
||||
'views/supplier_info_views.xml',
|
||||
'views/product_views.xml',
|
||||
|
||||
@@ -7,6 +7,7 @@ from . import res_partner
|
||||
from . import stock_move
|
||||
from . import stock_move_line
|
||||
from . import stock_picking
|
||||
from . import stock_quant
|
||||
from . import stock_rule
|
||||
from . import stock_warehouse
|
||||
from . import mrp_production
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class StockQuant(models.Model):
|
||||
_inherit = 'stock.quant'
|
||||
|
||||
is_subcontract = fields.Boolean(store=False, search='_search_is_subcontract')
|
||||
|
||||
def _search_is_subcontract(self, operator, value):
|
||||
if operator not in ['=', '!='] or not isinstance(value, bool):
|
||||
raise UserError(_('Operation not supported'))
|
||||
|
||||
subcontract_locations = self.env['res.company'].search([]).subcontracting_location_id
|
||||
|
||||
quant_ids = self.env['stock.quant'].search([
|
||||
('location_id', 'in', subcontract_locations.ids),
|
||||
]).ids
|
||||
if (operator == '!=' and value is True) or (operator == '=' and value is False):
|
||||
domain_operator = 'not in'
|
||||
else:
|
||||
domain_operator = 'in'
|
||||
return [('id', domain_operator, quant_ids)]
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="quant_subcontracting_search_view" model="ir.ui.view">
|
||||
<field name="name">stock.quant.subcontracting.search</field>
|
||||
<field name="model">stock.quant</field>
|
||||
<field name="inherit_id" ref="stock.quant_search_view" />
|
||||
<field name="groups_id" eval="[(4, ref('mrp.group_mrp_user'))]"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//filter[@name='transit_loc']" position="after">
|
||||
<filter string="Subcontracting Locations" name="is_subcontract" domain="[('is_subcontract', '=', True)]" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
<group expand='0' string='Filters'>
|
||||
<filter name='internal_loc' string="Internal Locations" domain="[('location_id.usage','=', 'internal')]"/>
|
||||
<filter name='transit_loc' string="Transit Locations" domain="[('location_id.usage' ,'=', 'transit')]"/>
|
||||
<separator/>
|
||||
<filter name="on_hand" string="On Hand" domain="[('on_hand', '=', True)]"/>
|
||||
<filter name="to_count" string="To Count" domain="[('inventory_date', '<=', context_today().strftime('%Y-%m-%d'))]"/>
|
||||
<filter name="to_apply" string="To Apply" domain="[('inventory_quantity_set', '=', True)]"/>
|
||||
<separator/>
|
||||
<filter name="negative" string="Negative Stock" domain="[('quantity', '<', 0.0)]"/>
|
||||
@@ -27,7 +29,6 @@
|
||||
<filter name="filter_in_date" date="in_date"/>
|
||||
<separator/>
|
||||
<filter name="my_count" string="My Counts" domain="[('user_id', '=', uid)]"/>
|
||||
<filter name="to_count" string="To Count" domain="[('inventory_date', '<=', context_today().strftime('%Y-%m-%d'))]"/>
|
||||
</group>
|
||||
<group expand='0' string='Group by...'>
|
||||
<filter string='Product' name="productgroup" context="{'group_by': 'product_id'}"/>
|
||||
|
||||
Reference in New Issue
Block a user