Group sale invoices from rental

This commit is contained in:
Cédric Krier
2024-06-05 14:48:53 +02:00
parent e576fcacc9
commit c39c64c1c8
3 changed files with 28 additions and 3 deletions
+1
View File
@@ -1,3 +1,4 @@
* Group with rental invoices
Version 7.6.0 - 2025-04-28
--------------------------
+21 -3
View File
@@ -7,8 +7,8 @@ from trytond.pool import PoolMeta
from trytond.transaction import Transaction
class Sale(metaclass=PoolMeta):
__name__ = 'sale.sale'
class InvoiceGroupingMixin:
__slots__ = ()
@property
def invoice_grouping_method(self):
@@ -17,7 +17,7 @@ class Sale(metaclass=PoolMeta):
@property
def _invoice_grouping_origins(self):
return ['sale.line']
return ['sale.line', 'sale.rental.line']
def _get_invoice_grouping_fields(self, invoice):
return {'state', 'company', 'type', 'journal', 'party',
@@ -59,6 +59,10 @@ class Sale(metaclass=PoolMeta):
invoice, = grouped_invoices
return invoice
class Sale(InvoiceGroupingMixin, metaclass=PoolMeta):
__name__ = 'sale.sale'
@classmethod
def _process_invoice(cls, sales):
for method, sales in groupby(
@@ -68,3 +72,17 @@ class Sale(metaclass=PoolMeta):
super()._process_invoice([sale])
else:
super()._process_invoice(list(sales))
class Rental(InvoiceGroupingMixin, metaclass=PoolMeta):
__name__ = 'sale.rental'
@classmethod
def invoice(cls, rentals):
for method, rentals in groupby(
rentals, lambda r: r.invoice_grouping_method):
if method:
for rental in rentals:
super().invoice([rental])
else:
super().invoice(list(rentals))
+6
View File
@@ -6,6 +6,8 @@ depends:
party
account_invoice
sale
extras_depend:
sale_rental
xml:
party.xml
configuration.xml
@@ -17,3 +19,7 @@ model:
configuration.Configuration
configuration.ConfigurationSaleMethod
sale.Sale
[register sale_rental]
model:
sale.Rental