diff --git a/modules/commission/CHANGELOG b/modules/commission/CHANGELOG index 81dd8a4ca3..91a7aedf0d 100644 --- a/modules/commission/CHANGELOG +++ b/modules/commission/CHANGELOG @@ -1,3 +1,5 @@ +* Allow searching reporting records by name + Version 6.6.0 - 2022-10-31 -------------------------- * Bug fixes (see mercurial logs for details) diff --git a/modules/commission/commission_reporting.py b/modules/commission/commission_reporting.py index 1d966d932f..3aeec2d2d6 100644 --- a/modules/commission/commission_reporting.py +++ b/modules/commission/commission_reporting.py @@ -150,6 +150,13 @@ class Agent(ModelView, ModelSQL): def get_currency(self, name): return self.agent.currency.id + def get_rec_name(self, name): + return self.agent.rec_name + + @classmethod + def search_rec_name(cls, name, clause): + return [('agent.rec_name', *clause[1:])] + class AgentTimeseries(Agent): "Commission Reporting per Agent" diff --git a/modules/purchase/CHANGELOG b/modules/purchase/CHANGELOG index ae37503f40..973a17941f 100644 --- a/modules/purchase/CHANGELOG +++ b/modules/purchase/CHANGELOG @@ -1,3 +1,5 @@ +* Allow searching reporting records by name + Version 6.6.0 - 2022-10-31 -------------------------- * Bug fixes (see mercurial logs for details) diff --git a/modules/purchase/purchase_reporting.py b/modules/purchase/purchase_reporting.py index 249f86eed8..3f641abdd7 100644 --- a/modules/purchase/purchase_reporting.py +++ b/modules/purchase/purchase_reporting.py @@ -281,6 +281,10 @@ class SupplierMixin(object): def get_rec_name(self, name): return self.supplier.rec_name + @classmethod + def search_rec_name(cls, name, clause): + return [('supplier.rec_name', *clause[1:])] + class Supplier(SupplierMixin, Abstract, ModelView): "Purchase Reporting per Supplier" @@ -352,6 +356,10 @@ class ProductMixin(object): name += '@%s' % supplier.rec_name return name + @classmethod + def search_rec_name(cls, name, clause): + return [('product.rec_name', *clause[1:])] + class Product(ProductMixin, Abstract, ModelView): "Purchase Reporting per Product" diff --git a/modules/sale/CHANGELOG b/modules/sale/CHANGELOG index c279c7110e..b5b2a7aa60 100644 --- a/modules/sale/CHANGELOG +++ b/modules/sale/CHANGELOG @@ -1,3 +1,5 @@ +* Allow searching reporting records by name + Version 6.6.0 - 2022-10-31 -------------------------- * Bug fixes (see mercurial logs for details) diff --git a/modules/sale/sale_reporting.py b/modules/sale/sale_reporting.py index 48fb7128e1..7c94553826 100644 --- a/modules/sale/sale_reporting.py +++ b/modules/sale/sale_reporting.py @@ -352,6 +352,10 @@ class CustomerMixin(object): def get_rec_name(self, name): return self.customer.rec_name + @classmethod + def search_rec_name(cls, name, clause): + return [('customer.rec_name', *clause[1:])] + class Customer(CustomerMixin, Abstract, ModelView): "Sale Reporting per Customer" @@ -436,6 +440,10 @@ class CustomerCategoryMixin: def get_rec_name(self, name): return self.category.rec_name if self.category else None + @classmethod + def search_rec_name(cls, name, clause): + return [('category.rec_name', *clause[1:])] + class CustomerCategory(CustomerCategoryMixin, Abstract, ModelView): "Sale Reporting per Customer Category" @@ -466,7 +474,8 @@ class CustomerCategoryTree(ModelSQL, ModelView): "Sale Reporting per Customer Category" __name__ = 'sale.reporting.customer.category.tree' - name = fields.Function(fields.Char("Name"), 'get_name') + name = fields.Function( + fields.Char("Name"), 'get_name', searcher='search_name') parent = fields.Many2One('sale.reporting.customer.category.tree', "Parent") children = fields.One2Many( 'sale.reporting.customer.category.tree', 'parent', "Children") @@ -494,6 +503,12 @@ class CustomerCategoryTree(ModelSQL, ModelView): categories = Category.browse(categories) return {c.id: c.name for c in categories} + @classmethod + def search_name(cls, name, clause): + pool = Pool() + Category = pool.get('party.category') + return [('id', 'in', Category.search([clause], query=True))] + @classmethod def order_name(cls, tables): pool = Pool() @@ -607,6 +622,10 @@ class ProductMixin(object): def get_rec_name(self, name): return self.product.rec_name if self.product else None + @classmethod + def search_rec_name(cls, name, clause): + return [('product.rec_name', *clause[1:])] + class Product(ProductMixin, Abstract, ModelView): "Sale Reporting per Product" @@ -696,6 +715,10 @@ class ProductCategoryMixin(object): def get_rec_name(self, name): return self.category.rec_name if self.category else None + @classmethod + def search_rec_name(cls, name, clause): + return [('category.rec_name', *clause[1:])] + class ProductCategory(ProductCategoryMixin, Abstract, ModelView): "Sale Reporting per Product Category" @@ -726,7 +749,8 @@ class ProductCategoryTree(ModelSQL, ModelView): "Sale Reporting per Product Category" __name__ = 'sale.reporting.product.category.tree' - name = fields.Function(fields.Char("Name"), 'get_name') + name = fields.Function( + fields.Char("Name"), 'get_name', searcher='search_name') parent = fields.Many2One('sale.reporting.product.category.tree', "Parent") children = fields.One2Many( 'sale.reporting.product.category.tree', 'parent', "Children") @@ -754,6 +778,12 @@ class ProductCategoryTree(ModelSQL, ModelView): categories = Category.browse(categories) return {c.id: c.name for c in categories} + @classmethod + def search_name(cls, name, clause): + pool = Pool() + Category = pool.get('product.category') + return [('id', 'in', Category.search([clause], query=True))] + @classmethod def order_name(cls, tables): pool = Pool() @@ -871,6 +901,13 @@ class CountryMixin(object): where &= address.country != Null return where + def get_rec_name(self, name): + return self.country.rec_name + + @classmethod + def search_rec_name(cls, name, clause): + return [('country.rec_name', *clause[1:])] + class RegionTree(ModelSQL, ModelView): "Sale Reporting per Region" @@ -1022,9 +1059,6 @@ class Country(CountryMixin, Abstract): address = tables['line.shipment_address'] return address.country - def get_rec_name(self, name): - return self.country.rec_name - class CountryTimeseries(CountryMixin, AbstractTimeseries, ModelView): "Sale Reporting per Country" @@ -1054,6 +1088,13 @@ class SubdivisionMixin(CountryMixin): where &= address.subdivision != Null return where + def get_rec_name(self, name): + return self.subdivision.rec_name + + @classmethod + def search_rec_name(cls, name, clause): + return [('subdivision.rec_name', *clause[1:])] + class Subdivision(SubdivisionMixin, Abstract): "Sale Reporting per Subdivision" @@ -1073,9 +1114,6 @@ class Subdivision(SubdivisionMixin, Abstract): address = tables['line.shipment_address'] return address.subdivision - def get_rec_name(self, name): - return self.subdivision.rec_name - class SubdivisionTimeseries(SubdivisionMixin, AbstractTimeseries, ModelView): "Sale Reporting per Subdivision" diff --git a/modules/sale/tests/scenario_sale_reporting.rst b/modules/sale/tests/scenario_sale_reporting.rst index f699ab198e..91515a769e 100644 --- a/modules/sale/tests/scenario_sale_reporting.rst +++ b/modules/sale/tests/scenario_sale_reporting.rst @@ -213,6 +213,9 @@ Check sale reporting per customer categories:: ... ('Child2', Decimal('10')), ... ('Root2', Decimal('30'))]) True + >>> child1, = CustomerCategoryTree.find([('rec_name', '=', 'Child1')]) + >>> child1.rec_name + 'Child1' Check sale reporting per product:: @@ -280,6 +283,9 @@ Check sale reporting per product categories:: ... ('Root2', Decimal('30')), ... ('Account Category', Decimal('40'))]) True + >>> child1, = ProductCategoryTree.find([('rec_name', '=', 'Child1')]) + >>> child1.rec_name + 'Child1' Check sale reporting per countries:: diff --git a/modules/sale_opportunity/CHANGELOG b/modules/sale_opportunity/CHANGELOG index 21b03be7ed..1d2484edc5 100644 --- a/modules/sale_opportunity/CHANGELOG +++ b/modules/sale_opportunity/CHANGELOG @@ -1,3 +1,5 @@ +* Allow searching reporting by record name + Version 6.6.0 - 2022-10-31 -------------------------- * Bug fixes (see mercurial logs for details) diff --git a/modules/sale_opportunity/opportunity_reporting.py b/modules/sale_opportunity/opportunity_reporting.py index 2f453f033d..273602374c 100644 --- a/modules/sale_opportunity/opportunity_reporting.py +++ b/modules/sale_opportunity/opportunity_reporting.py @@ -433,6 +433,10 @@ class EmployeeMixin: def get_rec_name(self, name): return self.employee.rec_name + @classmethod + def search_rec_name(cls, name, clause): + return [('employee.rec_name', *clause[1:])] + class ConversionEmployee(EmployeeMixin, AbstractConversion, ModelView): "Sale Opportunity Reporting Conversion per Employee" diff --git a/modules/stock/CHANGELOG b/modules/stock/CHANGELOG index 7e44592fbf..1d7b3a9ad9 100644 --- a/modules/stock/CHANGELOG +++ b/modules/stock/CHANGELOG @@ -1,3 +1,4 @@ +* Allow searching reporting records by name * Assign all possible shipments when trying * Store warehouse locations on shipments diff --git a/modules/stock/stock_reporting_margin.py b/modules/stock/stock_reporting_margin.py index a760b32ac5..a20f364d20 100644 --- a/modules/stock/stock_reporting_margin.py +++ b/modules/stock/stock_reporting_margin.py @@ -413,6 +413,10 @@ class ProductMixin: def get_rec_name(self, name): return self.product.rec_name + @classmethod + def search_rec_name(cls, name, clause): + return [('product.rec_name', *clause[1:])] + def get_quantity(self, name): return self.unit.round(self.internal_quantity) @@ -500,6 +504,10 @@ class CategoryMixin: def get_rec_name(self, name): return self.category.rec_name if self.category else None + @classmethod + def search_rec_name(cls, name, clause): + return [('category.rec_name', *clause[1:])] + class Category(CategoryMixin, Abstract, ModelView): "Stock Reporting Margin per Category" @@ -529,7 +537,8 @@ class CategoryTree(ModelSQL, ModelView): "Stock Reporting Margin per Category" __name__ = 'stock.reporting.margin.category.tree' - name = fields.Function(fields.Char("Name"), 'get_name') + name = fields.Function( + fields.Char("Name"), 'get_name', searcher='search_name') parent = fields.Many2One('stock.reporting.margin.category.tree', "Parent") children = fields.One2Many( 'stock.reporting.margin.category.tree', 'parent', "Children") @@ -573,6 +582,12 @@ class CategoryTree(ModelSQL, ModelView): categories = Category.browse(categories) return {c.id: c.name for c in categories} + @classmethod + def search_name(cls, name, clause): + pool = Pool() + Category = pool.get('product.category') + return [('id', 'in', Category.search([clause], query=True))] + @classmethod def order_name(cls, tables): pool = Pool() diff --git a/modules/stock/tests/scenario_stock_reporting_margin.rst b/modules/stock/tests/scenario_stock_reporting_margin.rst index e088b0f2cf..70fea9e35f 100644 --- a/modules/stock/tests/scenario_stock_reporting_margin.rst +++ b/modules/stock/tests/scenario_stock_reporting_margin.rst @@ -204,6 +204,9 @@ Check reporting margin per categories:: ... ('Child2', Decimal('40.00'), Decimal('100.00'), ... Decimal('60.00'), Decimal('0.6000'))]) True + >>> child1, = MarginCategoryTree.find([('rec_name', '=', 'Child1')]) + >>> child1.rec_name + 'Child1' Check reporting margin including lost::