Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
10 changes: 6 additions & 4 deletions product_catalog_tree/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def _inverse_catalog_values(self, product_catalog_qty):

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

def increase_quantity(self):
for rec in self:
Expand Down
Loading