[FIX] pos_sale_margin: correctly compute margin when no cost is set
Current behavior: If there was no cost set on a product, the margin couldn't be calculated for the PoS sale report. Steps to reproduce: - Install PoS and Sales - Create a product with no cost - Open a session and make an order with this item - Close the session and go to the PoS sale report - Add the margin measure to the report, and show the stats by product - The new product does not have any margin. opw-3120208 closes odoo/odoo#110429 X-original-commit: 9105f803095d7ddb07bc62ec1e2f2982215e273e Signed-off-by: Trinh Jacky (trj) <trj@odoo.com> Signed-off-by: Engels Robin (roen) <roen@odoo.com>
This commit is contained in:
@@ -9,5 +9,5 @@ class SaleReport(models.Model):
|
||||
|
||||
def _fill_pos_fields(self, additional_fields):
|
||||
values = super()._fill_pos_fields(additional_fields)
|
||||
values['margin'] = 'SUM(l.price_subtotal - l.total_cost / CASE COALESCE(pos.currency_rate, 0) WHEN 0 THEN 1.0 ELSE pos.currency_rate END)'
|
||||
values['margin'] = 'SUM(l.price_subtotal - COALESCE(l.total_cost,0) / CASE COALESCE(pos.currency_rate, 0) WHEN 0 THEN 1.0 ELSE pos.currency_rate END)'
|
||||
return values
|
||||
|
||||
Reference in New Issue
Block a user