[IMP] mrp: workcenters views

Some changes on the MRP workcenter model (`mrp.workcenter`):

  - Adds a stat button in the form view to display operations used by
    the workcenter;

  - Enables the multi-edit on the list view;

  - Adds multiple fields in the list view, often as optional;

task-2382256

closes odoo/odoo#62126

Related: odoo/enterprise#17250
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
This commit is contained in:
svs-odoo
2021-03-24 08:21:34 +00:00
parent 38ac9ccbc1
commit 02bd058800
2 changed files with 27 additions and 4 deletions
+11 -2
View File
@@ -36,8 +36,8 @@ class MrpWorkcenter(models.Model):
help="Gives the sequence order when displaying a list of work centers.")
color = fields.Integer('Color')
costs_hour = fields.Float(string='Cost per hour', help='Specify cost of work center per hour.', default=0.0)
time_start = fields.Float('Time before prod.', help="Time in minutes for the setup.")
time_stop = fields.Float('Time after prod.', help="Time in minutes for the cleaning.")
time_start = fields.Float('Setup Time', help="Time in minutes for the setup.")
time_stop = fields.Float('Cleanup Time', help="Time in minutes for the cleaning.")
routing_line_ids = fields.One2many('mrp.routing.workcenter', 'workcenter_id', "Routing Lines")
order_ids = fields.One2many('mrp.workorder', 'workcenter_id', "Orders")
workorder_count = fields.Integer('# Work Orders', compute='_compute_workorder_count')
@@ -192,6 +192,15 @@ class MrpWorkcenter(models.Model):
self.resource_id.company_id = vals['company_id']
return super(MrpWorkcenter, self).write(vals)
def action_show_operations(self):
self.ensure_one()
action = self.env['ir.actions.actions']._for_xml_id('mrp.mrp_routing_action')
action['domain'] = [('workcenter_id', '=', self.id)]
action['context'] = {
'default_workcenter_id': self.id,
}
return action
def action_work_order(self):
action = self.env["ir.actions.actions"]._for_xml_id("mrp.action_work_orders")
return action
+16 -2
View File
@@ -32,10 +32,18 @@
<field name="name">mrp.workcenter.tree</field>
<field name="model">mrp.workcenter</field>
<field name="arch" type="xml">
<tree string="Work Center">
<tree string="Work Center" multi_edit="1">
<field name="sequence" widget="handle"/>
<field name="code"/>
<field name="name"/>
<field name="code"/>
<field name="alternative_workcenter_ids" widget="many2many_tags" optional="hide"/>
<field name="productive_time" optional="hide"/>
<field name="costs_hour"/>
<field name="capacity"/>
<field name="time_efficiency" optional="hide"/>
<field name="oee_target" optional="hide"/>
<field name="time_start" optional="hide"/>
<field name="time_stop" optional="hide"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="active" invisible="1"/>
</tree>
@@ -289,6 +297,12 @@
<form string="Work Center">
<sheet>
<div class="oe_button_box" name="button_box">
<field name="routing_line_ids" invisible="1"/>
<button string="Operations" type="object"
name="action_show_operations"
attrs="{'invisible': [('routing_line_ids', '=', [])]}"
context="{'default_workcenter_id': active_id}"
class="oe_stat_button" icon="fa-cog"/>
<button name="%(mrp_workcenter_productivity_report_oee)d" type="action" class="oe_stat_button" icon="fa-pie-chart">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value"><field name="oee" widget="statinfo" nolabel="1"/>%</span>