[IMP] repair: smarter smart buttons
Added a todo count field on the button where the lot is the product being repaired. Changed the texts to better fit the buttons. Part-of: odoo/odoo#129933
This commit is contained in:
@@ -9,6 +9,7 @@ class StockLot(models.Model):
|
||||
|
||||
repair_order_ids = fields.Many2many('repair.order', string="Repair Orders", compute="_compute_repair_order_ids")
|
||||
repair_order_count = fields.Integer('Repair order count', compute="_compute_repair_order_ids")
|
||||
in_repair_count = fields.Integer('In repair count', compute="_compute_in_repair_count")
|
||||
repaired_count = fields.Integer('Repaired count', compute='_compute_repaired_count')
|
||||
|
||||
@api.depends('name')
|
||||
@@ -21,9 +22,17 @@ class StockLot(models.Model):
|
||||
lot.repair_order_ids = repair_orders[lot.id]
|
||||
lot.repair_order_count = len(lot.repair_order_ids)
|
||||
|
||||
def _compute_repaired_count(self):
|
||||
def _compute_in_repair_count(self):
|
||||
lot_data = self.env['repair.order']._read_group([('lot_id', 'in', self.ids), ('state', 'not in', ('done', 'cancel'))], ['lot_id'], ['__count'])
|
||||
result = {lot.id: count for lot, count in lot_data}
|
||||
for lot in self:
|
||||
lot.repaired_count = len(self.env['repair.order'].search([('lot_id', '=', self.id), ('state', '=', 'done')]))
|
||||
lot.in_repair_count = result.get(lot.id, 0)
|
||||
|
||||
def _compute_repaired_count(self):
|
||||
lot_data = self.env['repair.order']._read_group([('lot_id', 'in', self.ids), ('state', '=', 'done')], ['lot_id'], ['__count'])
|
||||
result = {lot.id: count for lot, count in lot_data}
|
||||
for lot in self:
|
||||
lot.repaired_count = result.get(lot.id, 0)
|
||||
|
||||
def action_lot_open_repairs(self):
|
||||
action = self.env["ir.actions.actions"]._for_xml_id("repair.action_repair_order_tree")
|
||||
|
||||
@@ -9,19 +9,28 @@
|
||||
<button class="oe_stat_button" name="action_view_ro" type="object" icon="fa-wrench" help="Repair Orders"
|
||||
invisible="repair_order_count == 0 or not display_complete">
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_value">
|
||||
<field name="repair_order_count" widget="statinfo" nolabel="1" class="mr4"/>
|
||||
<span class="o_stat_text">Used</span>
|
||||
</span>
|
||||
<span class="o_stat_text">In Repairs</span>
|
||||
<div class="o_field_widget o_stat_info align-items-baseline flex-row gap-1 me-1">
|
||||
<span class="o_stat_text">Repair Parts:</span>
|
||||
<span class="o_stat_value">
|
||||
<field name="repair_order_count" widget="statinfo" nolabel="1" class="mr4"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
<button name="action_lot_open_repairs" icon="fa-wrench" class="oe_stat_button" type="object">
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_value">
|
||||
<field name="repaired_count" widget="statinfo" nolabel="1" class="mr4"/>
|
||||
</span>
|
||||
<span class="o_stat_text">Repaired</span>
|
||||
<div class="o_field_widget o_stat_info align-items-baseline flex-row gap-1 me-1">
|
||||
<span class="o_stat_text">To Do:</span>
|
||||
<span class="o_stat_value">
|
||||
<field name="in_repair_count" widget="statinfo" nolabel="1" class="mr4"/>
|
||||
</span>
|
||||
</div>
|
||||
<div class="o_field_widget o_stat_info align-items-baseline flex-row gap-1 me-1">
|
||||
<span class="o_stat_text">Done:</span>
|
||||
<span class="o_stat_value">
|
||||
<field name="repaired_count" widget="statinfo" nolabel="1" class="mr4"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</xpath>
|
||||
|
||||
Reference in New Issue
Block a user