Add sale_discount extra depends

#047505
This commit is contained in:
Raimon Esteve 2021-10-08 15:45:04 +02:00
parent 8fb6c4c0d1
commit 9286a2fa15
2 changed files with 9 additions and 0 deletions

View File

@ -262,18 +262,24 @@ class SaleRuleAction(ModelSQL, ModelView):
def apply_cart_discount_percentage(self, sale):
line = self.get_default_sale_line(sale)
line.unit_price = -(sale.total_amount * self.quantity / 100)
if hasattr(line, 'gross_unit_price'):
line.gross_unit_price = line.unit_price
line.amount = line.on_change_with_amount()
return line
def apply_cart_base_discount_percentage(self, sale):
line = self.get_default_sale_line(sale)
line.unit_price = -(sale.untaxed_amount * self.quantity / 100)
if hasattr(line, 'gross_unit_price'):
line.gross_unit_price = line.unit_price
line.amount = line.on_change_with_amount()
return line
def apply_cart_discount_fixed(self, sale):
line = self.get_default_sale_line(sale)
line.unit_price = -self.quantity
if hasattr(line, 'gross_unit_price'):
line.gross_unit_price = line.unit_price
line.amount = line.on_change_with_amount()
return line
@ -281,6 +287,8 @@ class SaleRuleAction(ModelSQL, ModelView):
line = self.get_default_sale_line(sale)
line.quantity = self.quantity
line.unit_price = 0
if hasattr(line, 'gross_unit_price'):
line.gross_unit_price = line.unit_price
line.amount = line.on_change_with_amount()
return line

View File

@ -7,6 +7,7 @@ depends:
sale_shop
extras_depend:
sale_pos
sale_discount
xml:
sale.xml
shop.xml