[FIX] repair: minor bugfixes
This commit fixes the following issues: 1. Before this commit, when adding a new move in a repair order, its default quantity was equal to the repair order's product quantity. The move's quantity should be 1 by default; 2. The `forecast_availability` is renamed from "Reserved" to "Forecasted"; 3. Removes the "Clear Quantities" button since it does basically the same thing than the "Unreserve" button. closes odoo/odoo#141849 Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
@@ -164,8 +164,8 @@ class Repair(models.Model):
|
||||
picking_product_ids = fields.One2many('product.product', compute='compute_picking_product_ids')
|
||||
picking_product_id = fields.Many2one(related="picking_id.product_id")
|
||||
# UI Fields
|
||||
show_set_qty_button = fields.Boolean(compute='_compute_show_qty_button')
|
||||
show_clear_qty_button = fields.Boolean(compute='_compute_show_qty_button')
|
||||
show_set_qty_button = fields.Boolean(compute='_compute_show_qty_button') # TODO: remove in master.
|
||||
show_clear_qty_button = fields.Boolean(compute='_compute_show_qty_button') # TODO: remove in master.
|
||||
unreserve_visible = fields.Boolean(
|
||||
'Allowed to Unreserve Production', compute='_compute_unreserve_visible',
|
||||
help='Technical field to check when we can unreserve')
|
||||
@@ -255,11 +255,6 @@ class Repair(models.Model):
|
||||
def _compute_show_qty_button(self):
|
||||
self.show_set_qty_button = False
|
||||
self.show_clear_qty_button = False
|
||||
for repair in self.filtered(lambda r: r.state not in ['cancel', 'done']):
|
||||
if any(float_is_zero(m.quantity, precision_rounding=m.product_uom.rounding) and not float_is_zero(m.product_uom_qty, precision_rounding=m.product_uom.rounding) for m in repair.move_ids):
|
||||
repair.show_set_qty_button = True
|
||||
elif any(not float_is_zero(m.quantity, precision_rounding=m.product_uom.rounding) for m in repair.move_ids):
|
||||
repair.show_clear_qty_button = True
|
||||
|
||||
@api.depends('move_ids', 'state', 'move_ids.product_uom_qty')
|
||||
def _compute_unreserve_visible(self):
|
||||
@@ -267,7 +262,10 @@ class Repair(models.Model):
|
||||
already_reserved = repair.state not in ('done', 'cancel') and any(repair.mapped('move_ids.move_line_ids.quantity'))
|
||||
|
||||
repair.unreserve_visible = already_reserved
|
||||
repair.reserve_visible = repair.state in ('confirmed', 'under_repair') and any(move.product_uom_qty and move.state in ['confirmed', 'partially_available'] for move in repair.move_ids)
|
||||
repair.reserve_visible = (
|
||||
repair.state in ('confirmed', 'under_repair') and
|
||||
any(not move.picked and move.product_uom_qty and move.state in ['confirmed', 'partially_available'] for move in repair.move_ids)
|
||||
)
|
||||
|
||||
@api.onchange('product_uom')
|
||||
def onchange_product_uom(self):
|
||||
@@ -323,9 +321,6 @@ class Repair(models.Model):
|
||||
def action_assign(self):
|
||||
return self.move_ids._action_assign()
|
||||
|
||||
def action_clear_quantities_to_zero(self):
|
||||
return self.move_ids.filtered(lambda m: float_compare(m.quantity, m.reserved_availability, precision_rounding=m.product_uom.rounding) == 0)._clear_quantities_to_zero()
|
||||
|
||||
def action_create_sale_order(self):
|
||||
if any(repair.sale_order_id for repair in self):
|
||||
concerned_ro = self.filtered('sale_order_id')
|
||||
|
||||
@@ -61,13 +61,10 @@
|
||||
<form string="Repair Order">
|
||||
<field name="unreserve_visible" invisible="1"/>
|
||||
<field name="reserve_visible" invisible="1"/>
|
||||
<field name="show_set_qty_button" invisible="1"/>
|
||||
<field name="show_clear_qty_button" invisible="1"/>
|
||||
<header>
|
||||
<button name="action_validate" invisible="state != 'draft'" type="object" string="Confirm Repair" class="oe_highlight" data-hotkey="v"/>
|
||||
<button name="action_repair_start" invisible="state != 'confirmed'" type="object" string="Start Repair" class="oe_highlight" data-hotkey="q"/>
|
||||
<button name="action_repair_end" invisible="state != 'under_repair'" type="object" string="End Repair" class="oe_highlight" data-hotkey="x"/>
|
||||
<button name="action_clear_quantities_to_zero" invisible="not show_clear_qty_button" string="Clear quantities" type="object" groups="stock.group_stock_user" class="o_btn_validate" data-hotkey="g"/>
|
||||
<button name="action_assign" invisible="state in ('draft', 'done', 'cancel') or not reserve_visible" string="Check availability" type="object"/>
|
||||
<button name="action_unreserve" type="object" string="Unreserve" invisible="not unreserve_visible" data-hotkey="w"/>
|
||||
<button name="action_create_sale_order" type="object" string="Create Quotation" invisible="state == 'cancel' or sale_order_id"/>
|
||||
@@ -132,7 +129,7 @@
|
||||
<notebook>
|
||||
<page string="Parts" name="parts">
|
||||
<field name="move_ids" readonly="state == 'cancel' or state == 'done'"
|
||||
context="{'default_repair_id': id, 'default_product_uom_qty': product_qty, 'default_company_id': company_id, 'default_date': schedule_date, 'default_repair_line_type': 'add'}">
|
||||
context="{'default_repair_id': id, 'default_product_uom_qty': 1, 'default_company_id': company_id, 'default_date': schedule_date, 'default_repair_line_type': 'add'}">
|
||||
<tree string="Operations" editable="bottom">
|
||||
<field name="company_id" column_invisible="True"/>
|
||||
<field name="name" column_invisible="True"/>
|
||||
@@ -160,7 +157,7 @@
|
||||
<field name="product_packaging_id" groups="product.group_stock_packaging"/>
|
||||
<field name="product_uom_qty" string="Demand" readonly="state in ('done', 'cancel')"/>
|
||||
<field name="forecast_expected_date" column_invisible="True"/>
|
||||
<field name="forecast_availability" string="Reserved" column_invisible="parent.state in ('draft', 'done')" widget="forecast_widget"/>
|
||||
<field name="forecast_availability" string="Forecasted" column_invisible="parent.state in ('draft', 'done')" widget="forecast_widget"/>
|
||||
<field name="product_qty" readonly="1" column_invisible="True"/>
|
||||
<field name="quantity" string="Done" readonly="not product_id"/>
|
||||
<field name="product_uom" readonly="state != 'draft' and not additional" options="{'no_open': True, 'no_create': True}" string="Unit of Measure" groups="uom.group_uom"/>
|
||||
|
||||
Reference in New Issue
Block a user