[IMP] mrp: operations listview
On the MRP operation model (`mrp.routing.workcenter`):
- Changes the order (ordered by workcenter and BOM in priority);
- Adds computed field, `time_computed_on`, which is only used in list
view (display on how many numbers of work orders the duration is
computed);
- Adds multiple fields in list view (often optional display);
- Adds two groupby (by BOM and by workcenter).
task-2382256
This commit is contained in:
@@ -7,7 +7,7 @@ from odoo import api, fields, models, _
|
||||
class MrpRoutingWorkcenter(models.Model):
|
||||
_name = 'mrp.routing.workcenter'
|
||||
_description = 'Work Center Usage'
|
||||
_order = 'sequence, id'
|
||||
_order = 'bom_id, sequence, id'
|
||||
_check_company_auto = True
|
||||
|
||||
name = fields.Char('Operation', required=True)
|
||||
@@ -33,6 +33,7 @@ class MrpRoutingWorkcenter(models.Model):
|
||||
('manual', 'Set duration manually')], string='Duration Computation',
|
||||
default='manual')
|
||||
time_mode_batch = fields.Integer('Based on', default=10)
|
||||
time_computed_on = fields.Char('Computed on last', compute='_compute_time_computed_on')
|
||||
time_cycle_manual = fields.Float(
|
||||
'Manual Duration', default=60,
|
||||
help="Time in minutes:"
|
||||
@@ -42,6 +43,11 @@ class MrpRoutingWorkcenter(models.Model):
|
||||
workorder_count = fields.Integer("# Work Orders", compute="_compute_workorder_count")
|
||||
workorder_ids = fields.One2many('mrp.workorder', 'operation_id', string="Work Orders")
|
||||
|
||||
@api.depends('time_mode', 'time_mode_batch')
|
||||
def _compute_time_computed_on(self):
|
||||
for operation in self:
|
||||
operation.time_computed_on = _('%i work orders') % operation.time_mode_batch if operation.time_mode != 'manual' else False
|
||||
|
||||
@api.depends('time_cycle_manual', 'time_mode', 'workorder_ids')
|
||||
def _compute_time_cycle(self):
|
||||
manual_ops = self.filtered(lambda operation: operation.time_mode == 'manual')
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
<field name="operation_ids"
|
||||
attrs="{'invisible': [('type','not in',('normal','phantom'))]}"
|
||||
groups="mrp.group_mrp_routings"
|
||||
context="{'bom_id_invisible': True, 'default_company_id': company_id, 'default_bom_id': id}"/>
|
||||
context="{'bom_id_invisible': True, 'default_company_id': company_id, 'default_bom_id': id, 'tree_view_ref': 'mrp.mrp_routing_workcenter_bom_tree_view'}"/>
|
||||
</page>
|
||||
<page string="By-products"
|
||||
name="by_products"
|
||||
|
||||
@@ -6,15 +6,32 @@
|
||||
<field name="name">mrp.routing.workcenter.tree</field>
|
||||
<field name="model">mrp.routing.workcenter</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Routing Work Centers">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<tree string="Routing Work Centers" multi_edit="1">
|
||||
<field name="name"/>
|
||||
<field name="bom_id"/>
|
||||
<field name="workcenter_id"/>
|
||||
<field name="time_mode" optional="show"/>
|
||||
<field name="time_computed_on" optional="hide"/>
|
||||
<field name="time_cycle" widget="float_time" string="Duration (minutes)" sum="Total Duration" width="1.5"/>
|
||||
<field name="company_id" optional="show" groups="base.group_multi_company"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_routing_workcenter_bom_tree_view" model="ir.ui.view">
|
||||
<field name="name">mrp.routing.workcenter.bom.tree</field>
|
||||
<field name="model">mrp.routing.workcenter</field>
|
||||
<field name="inherit_id" ref="mrp_routing_workcenter_tree_view"/>
|
||||
<field name="priority">1000</field>
|
||||
<field name="mode">primary</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='name']" position="before">
|
||||
<field name="sequence" widget="handle"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='bom_id']" position="replace"/>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_routing_workcenter_form_view" model="ir.ui.view">
|
||||
<field name="name">mrp.routing.workcenter.form</field>
|
||||
<field name="model">mrp.routing.workcenter</field>
|
||||
@@ -75,6 +92,21 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="mrp_routing_workcenter_filter" model="ir.ui.view">
|
||||
<field name="name">mrp.routing.workcenter.filter</field>
|
||||
<field name="model">mrp.routing.workcenter</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Operations Search Filters">
|
||||
<field name="bom_id"/>
|
||||
<field name="workcenter_id"/>
|
||||
<group>
|
||||
<filter string="Bill of Material" name="bom" context="{'group_by': 'bom_id'}"/>
|
||||
<filter string="Workcenter" name="workcenter" context="{'group_by': 'workcenter_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_mrp_routing_action"
|
||||
action="mrp_routing_action"
|
||||
parent="menu_mrp_configuration"
|
||||
|
||||
Reference in New Issue
Block a user