Skip to content

Commit

Permalink
[FIX]product_analytic: ensure move type in dict
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillemCForgeFlow authored and JasminSForgeFlow committed Jul 5, 2023
1 parent 3b016ba commit f5b75a3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions product_analytic/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ class AccountMoveLine(models.Model):
@api.onchange("product_id")
def _onchange_product_id(self):
res = super()._onchange_product_id()
for line in self:
inv_type = line.move_id.move_type
if line.product_id and inv_type:
ana_accounts = (
line.product_id.product_tmpl_id._get_product_analytic_accounts()
)
ana_account = ana_accounts[INV_TYPE_MAP[inv_type]]
line.analytic_account_id = ana_account.id
inv_type = self.move_id.move_type
if self.product_id and inv_type and inv_type in INV_TYPE_MAP.keys():
ana_accounts = (
self.product_id.product_tmpl_id._get_product_analytic_accounts()
)
ana_account = ana_accounts[INV_TYPE_MAP[inv_type]]
self.analytic_account_id = ana_account.id
return res

@api.model_create_multi
Expand All @@ -35,7 +34,8 @@ def create(self, vals_list):
inv_type = self.env["account.move"].browse([vals.get("move_id")]).move_type
if (
vals.get("product_id")
and inv_type != "entry"
and inv_type
and inv_type in INV_TYPE_MAP.keys()
and not vals.get("analytic_account_id")
):
product = self.env["product.product"].browse(vals.get("product_id"))
Expand Down

0 comments on commit f5b75a3

Please sign in to comment.