Skip to content

Commit 14afc36

Browse files
committed
[FIX]product_catalog_tree: take into account catalog from account.move
1 parent d6c49a0 commit 14afc36

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

product_catalog_tree/models/account_move.py

Whitespace-only changes.

product_catalog_tree/models/product_product.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ def _inverse_catalog_values(self, product_catalog_qty):
5858

5959
order = self.env[res_model].browse(order_id)
6060
for rec in self:
61-
existing_lines = order.order_line.filtered(lambda line: line.product_id.id == rec.id)
61+
if res_model == "account.move":
62+
existing_lines = order.invoice_line_ids.filtered(lambda line: line.product_id.id == rec.id)
63+
else:
64+
existing_lines = order.order_line.filtered(lambda line: line.product_id.id == rec.id)
6265
if len(existing_lines) > 1 and product_catalog_qty > 0:
6366
total_current_qty = sum(existing_lines.mapped("product_uom_qty"))
6467
qty_difference = product_catalog_qty - total_current_qty
@@ -75,9 +78,8 @@ def _inverse_catalog_values(self, product_catalog_qty):
7578
else:
7679
# Actualizar la información de la línea de orden
7780
# Call the order method with a cleared context to avoid errors on creating move line
78-
order.with_company(order.company_id).with_context(**{})._update_order_line_info(
79-
rec.id, product_catalog_qty
80-
)
81+
order = order.with_env(self.env(context={})).with_company(order.company_id)
82+
order._update_order_line_info(rec.id, product_catalog_qty)
8183

8284
def increase_quantity(self):
8385
for rec in self:

0 commit comments

Comments
 (0)