From 9349e4cc4b393735cff5353eb476bbd7ca503cff Mon Sep 17 00:00:00 2001 From: Maxime Richez Date: Mon, 5 Apr 2021 15:43:14 +0200 Subject: [PATCH] Add document source on move of product quantities by warehouse issue9728 review318541003 --- CHANGELOG | 1 + product.py | 21 +++++++++++++++++++ ...product_quantities_warehouse_move_list.xml | 1 + 3 files changed, 23 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 26abe40d22..ea2317245b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Add document source on move of product quantities by warehouse * Add relate from assigned shipment to products quantities by warehouse * Show quantities by warehouse for many products * Default to ordering shipments by date diff --git a/product.py b/product.py index d0e6052b35..bdfa7de2cb 100644 --- a/product.py +++ b/product.py @@ -737,6 +737,9 @@ class ProductQuantitiesByWarehouseMove(ModelSQL, ModelView): date = fields.Date("Date") move = fields.Many2One('stock.move', "Move") origin = fields.Reference("Origin", selection='get_origin') + document = fields.Function( + fields.Reference("Document", selection='get_documents'), + 'get_document') quantity = fields.Float("Quantity") cumulative_quantity_start = fields.Function( fields.Float("Cumulative Quantity Start"), 'get_cumulative_quantity') @@ -836,6 +839,24 @@ class ProductQuantitiesByWarehouseMove(ModelSQL, ModelView): Move = pool.get('stock.move') return Move.get_origin() + @classmethod + def _get_document_models(cls): + pool = Pool() + Move = pool.get('stock.move') + return [m for m, _ in Move.get_shipment() if m] + + @classmethod + def get_documents(cls): + pool = Pool() + Model = pool.get('ir.model') + get_name = Model.get_name + models = cls._get_document_models() + return [(None, '')] + [(m, get_name(m)) for m in models] + + def get_document(self, name): + if self.move and self.move.shipment: + return str(self.move.shipment) + @classmethod def get_cumulative_quantity(cls, records, names): pool = Pool() diff --git a/view/product_quantities_warehouse_move_list.xml b/view/product_quantities_warehouse_move_list.xml index f97959fe09..3223e95e5e 100644 --- a/view/product_quantities_warehouse_move_list.xml +++ b/view/product_quantities_warehouse_move_list.xml @@ -6,6 +6,7 @@ this repository contains the full copyright notices and license terms. --> +