0

I would like to create invoice with 3 discount custom compute in odoo 15, everything almost done but price_subtotal always get wrong value like thisenter image description here
can anyone tell me what is missing please?

this is the method i have made

def _get_price_total_and_subtotal(self, price_unit=None, quantity=None, discount=None, discount_2=None, discount_3=None, currency=None, product=None, partner=None, taxes=None, move_type=None):
    self.ensure_one()
    return self._get_price_total_and_subtotal_model(
        price_unit=price_unit or self.price_unit,
        quantity=quantity or self.quantity,
        discount=discount or self.discount,
        discount_2=discount_2 or self.discount_2,
        discount_3=discount_3 or self.discount_3,
        currency=currency or self.currency_id,
        product=product or self.product_id,
        partner=partner or self.partner_id,
        taxes=taxes or self.tax_ids,
        move_type=move_type or self.move_id.move_type,
    )

add into this line
def _get_price_total_and_subtotal_model(self, price_unit, quantity, discount, discount_2, discount_3, currency, product, partner, taxes, move_type):

modify this line like this

    line_discount_price_unit = price_unit * (1 - (discount / 100.0))
    line_discount_price_unit2 = line_discount_price_unit * (1 - (discount_2 / 100.0))
    line_discount_price_unit3 = line_discount_price_unit2 * (1 - (discount_3 / 100.0))
    subtotal = quantity * line_discount_price_unit3
Akhmad Ali
  • 85
  • 6
  • Did you override [_get_price_total_and_subtotal](https://github.com/odoo/odoo/blob/15.0/addons/account/models/account_move.py#L3871) to update `discount` before calling super – Kenly Jan 05 '22 at 10:53
  • yes I did like this `def _get_price_total_and_subtotal(self, price_unit=None, quantity=None, discount=None, discount_2=None, discount_3=None, currency=None, product=None, partner=None, taxes=None, move_type=None):` – Akhmad Ali Jan 05 '22 at 11:22
  • What does the function return? – Kenly Jan 05 '22 at 11:52
  • please check the changes I've made – Akhmad Ali Jan 06 '22 at 02:23
  • `_get_price_total_and_subtotal_model` function has no parameter `discount_2` or `discount_3` – Kenly Jan 06 '22 at 10:27
  • I've tried to add them in this [def create(self, vals_list):](https://github.com/odoo/odoo/blob/9fae154ed7a00d0d482be73faf996eeec81103db/addons/account/models/account_move.py#L4491) – Akhmad Ali Jan 07 '22 at 03:13
  • but that method can't override – Akhmad Ali Jan 07 '22 at 03:15
  • Check the OCA [account_invoice_triple_discount](https://github.com/OCA/account-invoicing/blob/14.0/account_invoice_triple_discount/models/account_move_line.py#L70) v14 module (but still valid), they computed the value of `discount` before computing the subtotal – Kenly Jan 08 '22 at 11:40
  • Ok I'll check it – Akhmad Ali Jan 10 '22 at 01:48

0 Answers0