[IMP] mrp: work orders planning

This PR introduce:
- State on kanban cards
- Do not allow a start date greater then a stop date.

The purpose and details are explain in each specific commit

Task ID -1838642
Pad - https://pad.odoo.com/p/r.68c799c9a80a18157eefebc39452f311

closes odoo/odoo#25103
This commit is contained in:
Robot Odoo
2018-12-03 09:45:44 +01:00
committed by GitHub
2 changed files with 13 additions and 4 deletions
+8 -2
View File
@@ -64,7 +64,7 @@ class MrpWorkorder(models.Model):
compute='_compute_is_produced')
state = fields.Selection([
('pending', 'Pending'),
('pending', 'Waiting for another WO'),
('ready', 'Ready'),
('progress', 'In Progress'),
('done', 'Finished'),
@@ -230,8 +230,14 @@ class MrpWorkorder(models.Model):
@api.multi
def write(self, values):
if ('date_planned_start' in values or 'date_planned_finished' in values) and any(workorder.state == 'done' for workorder in self):
if list(values.keys()) != ['time_ids'] and any(workorder.state == 'done' for workorder in self):
raise UserError(_('You can not change the finished work order.'))
if 'date_planned_start' in values or 'date_planned_finished' in values:
for workorder in self:
start_date = fields.Datetime.to_datetime(values.get('date_planned_start')) or workorder.date_planned_start
end_date = fields.Datetime.to_datetime(values.get('date_planned_finished')) or workorder.date_planned_finished
if start_date and end_date and start_date > end_date:
raise UserError(_('The planned end date of the work order cannot be prior to the planned start date, please correct this to save the work order.'))
return super(MrpWorkorder, self).write(values)
def _generate_lot_ids(self):
+5 -2
View File
@@ -358,10 +358,13 @@
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_card oe_kanban_global_click">
<div class="oe_kanban_content">
<div>
<strong class="o_kanban_record_title">
<div class="o_kanban_record_top">
<strong class="o_kanban_record_headings">
<span><t t-esc="record.production_id.value"/></span> - <span><t t-esc="record.name.value"/></span>
</strong>
<span t-attf-class="badge #{['pending'].indexOf(record.state.raw_value) > -1 ? 'badge-warning' :['progress'].indexOf(record.state.raw_value) > -1 ? 'badge-secondary' : ['ready'].indexOf(record.state.raw_value) > -1 ? 'badge-primary' : ['done'].indexOf(record.state.raw_value) > -1 ? 'badge-success' : 'badge-danger'}">
<t t-esc="record.state.value"/>
</span>
</div>
<div class="o_kanban_record_bottom">
<div class="oe_kanban_bottom_left">