[FIX] mrp: usability fixes

- Default quantity on MO is 1.0
- Default quantity to consume on move is 1.0
- No open on the company_id from BoM form
- Optional=Hide for product, qty on BoM form
- Backorder button renamed to Validate
- Date deadline and origin to Miscellaneous tab
- Be able to remove stock_move when the MO is draft
- Some renaming in the menu and run scheduler under planning item

[FIX] mrp: fail to create stock.move after MO confirmation

Since the product_id on stock.move is readonly once it is set and the
MO is confirmed, it's not send to the server and the create crash
since product_id is NULL.

closes odoo/odoo#55270

Related: odoo/enterprise#12148
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
William Henrotin
2020-08-03 09:38:33 +00:00
parent 55c0d13104
commit 47e40e7f6a
5 changed files with 24 additions and 25 deletions
+1 -1
View File
@@ -579,7 +579,7 @@ class MrpProduction(models.Model):
def _onchange_bom_id(self):
if not self.product_id and self.bom_id:
self.product_id = self.bom_id.product_id or self.bom_id.product_tmpl_id.product_variant_ids[0]
self.product_qty = self.bom_id.product_qty
self.product_qty = self.bom_id.product_qty or 1.0
self.product_uom_id = self.bom_id and self.bom_id.product_uom_id.id or self.product_id.uom_id.id
self.move_raw_ids = [(2, move.id) for move in self.move_raw_ids.filtered(lambda m: m.bom_line_id)]
self.picking_type_id = self.bom_id.picking_type_id or self.picking_type_id
+4 -4
View File
@@ -71,7 +71,7 @@
</li>
</ul>
</p>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True, 'no_open': True}"/>
</group>
</group>
<notebook>
@@ -151,10 +151,10 @@
<field name="product_tmpl_id"/>
<field name="code" optional="show"/>
<field name="type"/>
<field name="product_id" groups="product.group_product_variant" optional="show"/>
<field name="product_id" groups="product.group_product_variant" optional="hide"/>
<field name="company_id" groups="base.group_multi_company" optional="show"/>
<field name="product_qty" optional="show"/>
<field name="product_uom_id" groups="uom.group_uom" optional="show" string="Unit of Measure"/>
<field name="product_qty" optional="hide"/>
<field name="product_uom_id" groups="uom.group_uom" optional="hide" string="Unit of Measure"/>
</tree>
</field>
</record>
+14 -13
View File
@@ -69,7 +69,7 @@
<header>
<field name="confirm_cancel" invisible="1"/>
<field name="show_lock" invisible="1"/>
<button name="button_mark_done" attrs="{'invisible': ['|', ('state', '!=', 'progress'), ('qty_producing', '=', 0)]}" string="Backorder" type="object" class="oe_highlight"/>
<button name="button_mark_done" attrs="{'invisible': ['|', ('state', '!=', 'progress'), ('qty_producing', '=', 0)]}" string="Validate" type="object" class="oe_highlight"/>
<button name="button_mark_done" attrs="{'invisible': [('state', '!=', 'to_close')]}" string="Mark as Done" type="object" class="oe_highlight"/>
<button name="action_confirm" attrs="{'invisible': [('state', '!=', 'draft')]}" string="Confirm" type="object" class="oe_highlight"/>
<button name="action_assign" attrs="{'invisible': ['|', ('state', 'in', ('draft', 'done', 'cancel')), ('reserve_visible', '=', False)]}" string="Check availability" type="object"/>
@@ -114,7 +114,7 @@
<button class="oe_stat_button" name="action_view_mrp_production_backorders" type="object" icon="fa-wrench" attrs="{'invisible': [('mrp_production_backorder_count', '&lt;', 2)]}">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value"><field name="mrp_production_backorder_count"/></span>
<span class="o_stat_text">Backorder MO's</span>
<span class="o_stat_text">Backorders</span>
</div>
</button>
<button class="oe_stat_button" name="action_see_move_scrap" type="object" icon="fa-arrows-v" attrs="{'invisible': [('scrap_count', '=', 0)]}">
@@ -166,7 +166,6 @@
context="{'default_product_tmpl_id': product_tmpl_id}" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
</group>
<group name="group_extra_info">
<field name="date_deadline"/>
<label for="date_planned_start"/>
<div class="o_row">
<field name="date_planned_start"
@@ -175,7 +174,6 @@
<field string=" " name="json_popover" widget="stock_rescheduling_popover" attrs="{'invisible': [('delay_alert_date', '=', False)]}"/>
</div>
<field name="user_id" domain="[('share', '=', False)]"/>
<field name="origin"/>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}" attrs="{'readonly': [('state', '!=', 'draft')]}" force_save="1"/>
<field name="show_final_lots" invisible="1"/>
<field name="production_location_id" invisible="1" readonly="1"/>
@@ -211,12 +209,11 @@
</group>
<notebook>
<page string="Components" name="components">
<field name="move_raw_ids"
context="{'default_date_expected': date_planned_start, 'default_location_id': location_src_id, 'default_location_dest_id': production_location_id, 'default_state': 'draft', 'default_raw_material_production_id': id, 'default_picking_type_id': picking_type_id, 'default_company_id': company_id}"
attrs="{'readonly': ['|', ('state', '=', 'cancel'), '&amp;', ('state', '=', 'done'), ('is_locked', '=', True)]}">
<tree delete="0" default_order="is_done,sequence" editable="bottom">
<field name="product_id" required="1" context="{'default_type': 'product'}" attrs="{'readonly': ['|', '|', ('has_move_lines', '=', True), ('state', '=', 'cancel'), '&amp;', ('state', '!=', 'draft'), ('additional', '=', False) ]}"/>
<field name="move_raw_ids"
context="{'default_product_uom_qty': 1.0, 'default_date_expected': date_planned_start, 'default_location_id': location_src_id, 'default_location_dest_id': production_location_id, 'default_state': 'draft', 'default_raw_material_production_id': id, 'default_picking_type_id': picking_type_id, 'default_company_id': company_id}"
attrs="{'readonly': ['|', ('state', '=', 'cancel'), '&amp;', ('state', '=', 'done'), ('is_locked', '=', True)]}" options="{'delete': [('state', '=', 'draft')]}">
<tree default_order="is_done,sequence" editable="bottom">
<field name="product_id" force_save="1" required="1" context="{'default_type': 'product'}" attrs="{'readonly': ['|', '|', ('has_move_lines', '=', True), ('state', '=', 'cancel'), '&amp;', ('state', '!=', 'draft'), ('additional', '=', False) ]}"/>
<field name="move_line_ids" invisible="1">
<tree>
<field name="lot_id" invisible="1"/>
@@ -272,8 +269,8 @@
<page string="Operations" name="operations" groups="mrp.group_mrp_routings">
<field name="workorder_ids" attrs="{'readonly': [('state', 'in', ['cancel', 'done'])]}" context="{'tree_view_ref': 'mrp.mrp_production_workorder_tree_editable_view', 'form_view_ref': 'mrp.mrp_production_workorder_form_view_inherit', 'default_production_id': id, 'default_product_uom_id': product_uom_id, 'default_consumption': consumption, 'default_company_id': company_id}"/> </page>
<page string="By-Products" name="finished_products" groups="mrp.group_mrp_byproducts">
<field name="move_byproduct_ids" context="{'default_location_id': production_location_id, 'default_location_dest_id': location_src_id, 'default_state': 'draft', 'default_production_id': id, 'default_picking_type_id': picking_type_id, 'default_company_id': company_id}" attrs="{'readonly': ['|', ('state', '=', 'cancel'), '&amp;', ('state', '=', 'done'), ('is_locked', '=', True)]}">
<tree delete="0" default_order="is_done,sequence" decoration-muted="is_done" editable="bottom">
<field name="move_byproduct_ids" context="{'default_location_id': production_location_id, 'default_location_dest_id': location_src_id, 'default_state': 'draft', 'default_production_id': id, 'default_picking_type_id': picking_type_id, 'default_company_id': company_id}" attrs="{'readonly': ['|', ('state', '=', 'cancel'), '&amp;', ('state', '=', 'done'), ('is_locked', '=', True)]}" options="{'delete': [('state', '=', 'draft')]}">
<tree default_order="is_done,sequence" decoration-muted="is_done" editable="bottom">
<field name="product_id" context="{'default_type': 'product'}" domain="[('id', '!=', parent.product_id)]" required="1"/>
<field name="move_line_ids" invisible="1">
@@ -323,13 +320,17 @@
</tree>
</field>
</page>
<page string="Miscellaneous" name="miscellaneous" groups="stock.group_stock_multi_locations">
<page string="Miscellaneous" name="miscellaneous">
<group>
<group>
<field name="picking_type_id" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
<field name="location_src_id" options="{'no_create': True}" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
<field name="location_dest_id" options="{'no_create': True}" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
</group>
<group>
<field name="date_deadline"/>
<field name="origin"/>
</group>
</group>
</page>
</notebook>
+2 -2
View File
@@ -48,14 +48,14 @@
sequence="15"/>
<menuitem id="menu_mrp_scrap"
name="Scrap Orders"
name="Scrap"
parent="menu_mrp_manufacturing"
action="stock.action_stock_scrap"
sequence="25"/>
<menuitem id="menu_procurement_compute_mrp"
action="stock.action_procurement_compute"
parent="menu_mrp_manufacturing"
parent="mrp_planning_menu_root"
sequence="135"/>
</odoo>
@@ -10,8 +10,6 @@
<form string="Create a Backorder">
<group>
<p>
You produced less than the initial demand.
</p><p class="text-muted">
Create a backorder if you expect to process the remaining products later. Do not create a backorder if you will not process the remaining products.
</p>
</group>
@@ -27,15 +25,15 @@
colspan="1" type="object" class="btn-primary" attrs="{'invisible': [('show_backorder_lines', '!=', False)]}"/>
<button name="action_backorder" string="Validate"
colspan="1" type="object" class="btn-primary" attrs="{'invisible': [('show_backorder_lines', '=', False)]}"/>
<button name="action_close_mo" type="object" string="Mark as Done" attrs="{'invisible': [('show_backorder_lines', '!=', False)]}"/>
<button string="Cancel" class="btn-secondary" special="cancel" />
<button name="action_close_mo" type="object" string="No Backorder" attrs="{'invisible': [('show_backorder_lines', '!=', False)]}"/>
<button string="Discard" class="btn-secondary" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="action_mrp_production_backorder" model="ir.actions.act_window">
<field name="name">Backorder</field>
<field name="name">You produced less than initial demand</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.production.backorder</field>
<field name="view_mode">form</field>