File tree Expand file tree Collapse file tree 3 files changed +49
-1
lines changed
Expand file tree Collapse file tree 3 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -278,3 +278,28 @@ def _get_contract_name_format(self):
278278 - Date: {date_text}
279279 """
280280 )
281+
282+ def _prepare_base_line_for_taxes_computation (self , ** kwargs ):
283+ """
284+ This is the base method for all line amounts computations.
285+ For 'is_contract' lines, we multiply the quantity by the recurrence.
286+ """
287+ self .ensure_one ()
288+ if self .is_contract :
289+ return self .env ["account.tax" ]._prepare_base_line_for_taxes_computation (
290+ self ,
291+ ** {
292+ "tax_ids" : self .tax_id ,
293+ "quantity" : self .product_uom_qty * self .recurrence_number ,
294+ "partner_id" : self .order_id .partner_id ,
295+ "currency_id" : self .order_id .currency_id
296+ or self .order_id .company_id .currency_id ,
297+ "rate" : self .order_id .currency_rate ,
298+ ** kwargs ,
299+ },
300+ )
301+ return super ()._prepare_base_line_for_taxes_computation (** kwargs )
302+
303+ @api .depends ("recurrence_number" )
304+ def _compute_amount (self ):
305+ return super ()._compute_amount ()
Original file line number Diff line number Diff line change @@ -615,3 +615,26 @@ def test_order_line_date_start_confirm(self):
615615 sale .order_line .contract_id .contract_line_ids .date_start ,
616616 fields .Date .to_date ("2025-02-28" ),
617617 )
618+
619+ def test_compute_amount (self ):
620+ """
621+ Check that recurrence is taken into account in line amounts.
622+ """
623+ tax = self .env ["account.tax" ].create (
624+ {
625+ "name" : "10% tax" ,
626+ "amount_type" : "percent" ,
627+ "amount" : 10 ,
628+ }
629+ )
630+ self .order_line1 .update (
631+ {
632+ "price_unit" : 100 ,
633+ "product_uom_qty" : 10 ,
634+ "recurrence_number" : 24 ,
635+ "tax_id" : [(4 , tax .id )],
636+ }
637+ )
638+ self .assertEqual (self .order_line1 .price_subtotal , 24000 )
639+ self .assertEqual (self .order_line1 .price_tax , 2400 )
640+ self .assertEqual (self .order_line1 .price_total , 26400 )
Original file line number Diff line number Diff line change 121121 domain =" [('contract_id','=',contract_id)]"
122122 optional =" hide"
123123 />
124- <field name =" recurrence_number" optional =" hide " />
124+ <field name =" recurrence_number" optional =" show " />
125125 <field name =" recurrence_interval" optional =" hide" />
126126 <field name =" recurring_interval" optional =" hide" />
127127 <field name =" recurring_rule_type" optional =" hide" />
You can’t perform that action at this time.
0 commit comments