diff options
| author | Rémy Voet (ryv) <ryv@odoo.com> | 2021-03-03 17:29:21 +0000 |
|---|---|---|
| committer | Rémy Voet (ryv) <ryv@odoo.com> | 2021-03-04 09:43:44 +0000 |
| commit | c9f55c5ecf174414f8e9ed6df56170ac2c6d6e3e (patch) | |
| tree | 7dc5d9ea2b86b0e201dbca99fc30a0099621d310 /addons/account/models/account_move.py | |
| parent | 336d5eee6484cfa66616560fdcca35cfcceb361d (diff) | |
[FIX] account: fix default context for `group_id`
Issue:
- Activate "Analytic Tags" and "Analytic Accounting" Settings
- Create an Analytic Tags and select "Analytic Distribution"
- Create Product -> Product type: Storable product, Update Quantity as
100, Sales Price like 100
- Product category -> Costing Method: Average Cost (AVCO)
Inventory Valuation: Automated
- Create Analytic Defaults Rules -> select created Analytic Tags
& Product.
- Create a SO -> Confirm it -> Delivery -> Validate it
then system give validation message message:
"The operation cannot be completed: another model requires the record
being deleted. If possible, archive it instead.
Model: Analytic Line (account.analytic.line),
Constraint: account_analytic_line_group_id_fkey”
But can be validated from the Inventory app.
Technical information:
It is due to the `default_group_id` in context put in
`action_view_delivery` method, it context key allows to create delivery
(tree view of `stock.picking`) with the correct `group_id`
("Procurement Group").
But the this name field is also used in the
`account.analytic.line` model. Moreover, the
the `_prepare_analytic_distribution_line` doesn't return any value for
`group_id` which means, that at the creation of the
`account.analytic.line` the `group_id` (id of `procurement.group`)
which will wrongly used.
Solution:
Because the `group_id` field on `account.analytic.line` is a related
store of `account_id.group_id`. We can set it directly in the
`_prepare_analytic_distribution_line` with the correct value.
opw-2442493
closes odoo/odoo#67183
Signed-off-by: William André (wan) <wan@odoo.com>
Diffstat (limited to 'addons/account/models/account_move.py')
| -rw-r--r-- | addons/account/models/account_move.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 0273aefc19e..961c6d7bff1 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -4727,6 +4727,7 @@ class AccountMoveLine(models.Model): 'name': default_name, 'date': self.date, 'account_id': distribution.account_id.id, + 'group_id': distribution.account_id.group_id.id, 'partner_id': self.partner_id.id, 'tag_ids': [(6, 0, [distribution.tag_id.id] + self._get_analytic_tag_ids())], 'unit_amount': self.quantity, |
