-
- Downloads
[FIX] mrp_account: generate analytic lines only once
When the analytic account feature is enabled, if a user marks a MO as
done and if it displays a wizard (consumption warning, backorder...),
the analytic lines will be generated twice.
To reproduce the issue:
(Need mrp_workorder, account_accountant)
1. In Settings, enable "Analytic Accounting"
2. Create a work center WC:
- Cost per hour: 100
- Analytic Account: a new analytic account AA
3. Create two products P_finished and P_compo
- P_finished is storable
- P_compo is consumable
4. Create a BoM:
- Product: P_finished
- Components: 1 x P_compo
- Operations: add a new one:
- Work Center: WC
5. Create and confirm a MO with 1 x P_finished
6. Start the WO for few seconds then mark it as done
7. Set the consumed qty of P_compo to 2
8. Mark the MO as done
- there is a consumption warning, confirm it
9. Open the account analytic lines related to AA
Error: there are two same lines for the MO, there should be only one
Step 8, when the user marks the MO as done, we call `button_mark_done`.
Because there is a consumption issue, this method returns an action (the
wizard with the consumption warning). However, in
`/mrp_account.button_mark_done`, we still generate the costs (this is
where the analytic lines will be generated). That is not correct since
the MO is not yet done. As a result, when confirming the consumption
warning, it leads again to `button_mark_done`, so we will generate the
cost a second time.
Note: this issue will happen each time the call of `button_mark_done`
does not mark the MO as done (for instance, in case of a backorder)
OPW-2972407
closes odoo/odoo#101528
Signed-off-by:
Tiffany Chang <tic@odoo.com>
Please register or sign in to comment