changeset a8ffeea52d87 in modules/account_invoice_stock:default
details: 
https://hg.tryton.org/modules/account_invoice_stock?cmd=changeset&node=a8ffeea52d87
description:
        Add shipments reference on invoice

        issue11141
        review360721002
diffstat:

 CHANGELOG  |   1 +
 account.py |  14 ++++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diffs (46 lines):

diff -r 157b5f9e2545 -r a8ffeea52d87 CHANGELOG
--- a/CHANGELOG Wed Mar 09 00:57:17 2022 +0100
+++ b/CHANGELOG Fri Mar 18 15:55:42 2022 +0100
@@ -1,3 +1,4 @@
+* Add shipments reference on invoice and invoice line
 * Add support for Python 3.10
 * Remove support for Python 3.6
 
diff -r 157b5f9e2545 -r a8ffeea52d87 account.py
--- a/account.py        Wed Mar 09 00:57:17 2022 +0100
+++ b/account.py        Fri Mar 18 15:55:42 2022 +0100
@@ -9,6 +9,14 @@
 class Invoice(metaclass=PoolMeta):
     __name__ = 'account.invoice'
 
+    shipments = fields.Function(fields.Char("Shipments"), 'get_shipments')
+
+    def get_shipments(self, name):
+        shipments = {
+            m.shipment.rec_name for l in self.lines
+            for m in l.stock_moves if m.shipment}
+        return ', '.join(sorted(shipments))
+
     @classmethod
     def _post(cls, invoices):
         pool = Pool()
@@ -61,6 +69,7 @@
                 | ~Eval('product')),
             },
         depends=['type', 'product_uom_category', 'invoice', 'invoice_type'])
+    shipments = fields.Function(fields.Char("Shipments"), 'get_shipments')
     correction = fields.Boolean(
         "Correction",
         states={
@@ -102,6 +111,11 @@
                     stock_move.uom, stock_move.quantity, self.unit)
         return quantity
 
+    def get_shipments(self, name):
+        shipments = {
+            m.shipment.rec_name for m in self.stock_moves if m.shipment}
+        return ', '.join(sorted(shipments))
+
     @classmethod
     def write(cls, *args):
         pool = Pool()

Reply via email to