Skip to content

[8.0 - 18.0] quality_control_stock[_oca] Done action filter #1713

@niecw

Description

@niecw

Module

quality_control_stock (quality_control_stock_oca in later versions)

Describe the bug

qc.inspection records may have following states: draft, ready, waiting, success, failed, and canceled

state = fields.Selection(
[('draft', 'Draft'),
('ready', 'Ready'),
('waiting', 'Waiting supervisor approval'),
('success', 'Quality success'),
('failed', 'Quality failed'),
('canceled', 'Canceled')],
string='State', readonly=True, default='draft')

In the quality_control_stock (quality_control_stock_oca in later versions) stock.move and stock.production.line is equipped with done_inspections field which is calculated as the number of failed + success records
self.passed_inspections = len([x for x in self.qc_inspections if
x.state == 'success'])
self.failed_inspections = len([x for x in self.qc_inspections if
x.state == 'failed'])
self.done_inspections = (self.passed_inspections +
self.failed_inspections)

However, in the stat button that shows that field
<button class="oe_inline oe_stat_button"
type="action"
name="%(action_qc_inspection_per_picking_done)d"
icon="fa-pencil">
<field name="done_inspections" widget="statinfo" />
</button>
links to an action that shows qc.inspection which state is not draft or waiting
<record id="action_qc_inspection_per_picking_done" model="ir.actions.act_window">
<field name="name">Quality inspection from picking done</field>
<field name="res_model">qc.inspection</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('picking', '=', active_id), ('state', 'not in', ['draft', 'waiting'])]</field>
</record>
which may be different from success + failed because there are ready and canceled states.

To Reproduce

8.0 - 18.0

Steps to reproduce the behavior:

  1. Install quality_control_stock (or quality_control_stock_oca in later versions)
  2. Create several qc.inspection records related to a certain stock.picking or stock.production.lot with varying state, especially create some with ready and canceled state.
  3. Go to the corresponding stock.picking or stock.production.lot, check the figure at the Done button, click the button to display the corresponding records. The number of corresponding records may be different from the figure at the Done button.

Expected behavior
The figure at the Done button should reflect the number of records that is pulled by clicking the button (or vv.)

Additional context
The best solution may be to change the filtering of action_qc_inspection_per_picking_done action

<field name="domain">[('picking', '=', active_id), ('state', 'not in', ['draft', 'waiting'])]</field>
to match the done_inspection logic, which is filter only those with success or failed state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions