details: https://code.tryton.org/tryton/commit/c4cb74da47ed
branch: default
user: Cédric Krier <[email protected]>
date: Mon Oct 20 18:11:09 2025 +0200
description:
Group invoice and shipment also per sale line component as origin
Closes #14302
diffstat:
modules/product_kit/sale.py | 8 ++++++++
modules/product_kit/tryton.cfg | 2 ++
modules/sale_invoice_grouping/sale.py | 8 +++++++-
modules/sale_shipment_grouping/sale.py | 8 +++++++-
4 files changed, 24 insertions(+), 2 deletions(-)
diffs (80 lines):
diff -r 8d359573d99e -r c4cb74da47ed modules/product_kit/sale.py
--- a/modules/product_kit/sale.py Fri Oct 17 14:08:46 2025 +0200
+++ b/modules/product_kit/sale.py Mon Oct 20 18:11:09 2025 +0200
@@ -54,6 +54,14 @@
def search_moves(cls, name, clause):
return super().search_moves(name, clause)
+ @property
+ def _invoice_grouping_origins(self):
+ return super()._shipment_grouping_origins + ['sale.line.component']
+
+ @property
+ def _shipment_grouping_origins(self):
+ return super()._shipment_grouping_origins + ['sale.line.component']
+
class Line(order_line_mixin('sale'), metaclass=PoolMeta):
__name__ = 'sale.line'
diff -r 8d359573d99e -r c4cb74da47ed modules/product_kit/tryton.cfg
--- a/modules/product_kit/tryton.cfg Fri Oct 17 14:08:46 2025 +0200
+++ b/modules/product_kit/tryton.cfg Mon Oct 20 18:11:09 2025 +0200
@@ -11,6 +11,8 @@
purchase_amendment
sale
sale_amendment
+ sale_invoice_grouping
+ sale_shipment_grouping
stock
xml:
product.xml
diff -r 8d359573d99e -r c4cb74da47ed modules/sale_invoice_grouping/sale.py
--- a/modules/sale_invoice_grouping/sale.py Fri Oct 17 14:08:46 2025 +0200
+++ b/modules/sale_invoice_grouping/sale.py Mon Oct 20 18:11:09 2025 +0200
@@ -15,6 +15,10 @@
party = self.invoice_party or self.party
return party.sale_invoice_grouping_method
+ @property
+ def _invoice_grouping_origins(self):
+ return ['sale.line']
+
def _get_invoice_grouping_fields(self, invoice):
return {'state', 'company', 'type', 'journal', 'party',
'invoice_address', 'currency', 'account', 'payment_term'}
@@ -27,7 +31,9 @@
"Returns a domain that will find invoices that should be grouped"
Invoice = invoice.__class__
invoice_domain = [
- ('lines.origin', 'like', 'sale.line,%'),
+ ['OR'] + [
+ ('lines.origin', 'like', f'{o},%')
+ for o in self._invoice_grouping_origins],
]
fields = self._get_invoice_grouping_fields(invoice)
defaults = Invoice.default_get(fields, with_rec_name=False)
diff -r 8d359573d99e -r c4cb74da47ed modules/sale_shipment_grouping/sale.py
--- a/modules/sale_shipment_grouping/sale.py Fri Oct 17 14:08:46 2025 +0200
+++ b/modules/sale_shipment_grouping/sale.py Mon Oct 20 18:11:09 2025 +0200
@@ -15,6 +15,10 @@
return self.party.sale_shipment_grouping_method
@property
+ def _shipment_grouping_origins(self):
+ return ['sale.line']
+
+ @property
def _shipment_grouping_state(self):
return {'draft', 'waiting'}
@@ -37,7 +41,9 @@
"Returns a domain that will find shipments that should be grouped"
Shipment = shipment.__class__
shipment_domain = [
- ('moves.origin', 'like', 'sale.line,%'),
+ ['OR'] + [
+ ('moves.origin', 'like', f'{o},%')
+ for o in self._shipment_grouping_origins],
('state', 'in', list(self._shipment_grouping_state)),
]
shipment_domain += self._get_grouped_shipment_planned_date(shipment)