Skip to content

Commit

Permalink
[FIX] send product qty with context instead vals
Browse files Browse the repository at this point in the history
  • Loading branch information
Saran440 committed Jul 26, 2024
1 parent 792343a commit b22a8b1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions budget_control_purchase/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ def uncommit_purchase_budget(self):
# analytic_account = fwd_line.to_analytic_account_id
# break
# Confirm vendor bill, do uncommit budget
context["product_qty"] = qty
purchase_line.with_context(**context).commit_budget(
reverse=move_type == "in_invoice",
move_line_id=ml.id,
# analytic_distribution=analytic_account,
product_qty=qty,
date=ml.date_commit,
)
5 changes: 2 additions & 3 deletions budget_control_purchase/models/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ def _get_po_line_account(self):

def _init_docline_budget_vals(self, budget_vals, analytic_id):
self.ensure_one()
product_qty = self.product_qty
if "product_qty" in budget_vals and budget_vals.get("product_qty"):
product_qty = budget_vals.pop("product_qty")
# Use product qty from context, if not, use line product_qty
product_qty = self.env.context.get("product_qty") or self.product_qty
percent_analytic = self[self._budget_analytic_field].get(str(analytic_id))
budget_vals["amount_currency"] = (
self.price_unit * product_qty * percent_analytic / 100
Expand Down

0 comments on commit b22a8b1

Please sign in to comment.