Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncing from upstream Vauxoo/addons-vauxoo (15.0) #335

Merged
merged 1 commit into from
Jul 11, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ def update_margin_threshold(env):

def recompute_margin_percent(env):
order_lines = env["sale.order.line"].search([])
order_lines._compute_margin()
env.add_to_compute(field=order_lines._fields["margin_percent"], records=order_lines)
order_lines.flush()
_logger.info("The margin percentage of %s records have been recomputed.", len(order_lines))
2 changes: 1 addition & 1 deletion sale_margin_percentage/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class SaleOrderLine(models.Model):
def _compute_margin(self):
res = super()._compute_margin()
for line in self:
currency = line.order_id.pricelist_id.currency_id
if not line.product_uom_qty:
line.margin_percent = 0.0
continue

currency = line.currency_id
if currency.is_zero(line.price_unit) or currency.is_zero(line.price_subtotal):
line.margin_percent = -1.0
continue
Expand Down
Loading