make warehouse searchable

This commit is contained in:
?ngel ?lvarez 2018-06-12 16:24:10 +02:00
parent 26e536cfa8
commit 3562c769ca
2 changed files with 41 additions and 0 deletions

40
search_warehouse.diff Normal file
View File

@ -0,0 +1,40 @@
diff -r 78ac887c5b7f location.py
--- a/trytond/trytond/modules/stock/location.py Tue Jun 12 16:16:43 2018 +0200
+++ b/trytond/trytond/modules/stock/location.py Tue Jun 12 16:19:53 2018 +0200
@@ -59,7 +59,7 @@
"Flat Children",
help="Check to restrict to one level of children.")
warehouse = fields.Function(fields.Many2One('stock.location', 'Warehouse'),
- 'get_warehouse')
+ 'get_warehouse', searcher='search_warehouse')
input_location = fields.Many2One(
"stock.location", "Input", states={
'invisible': Eval('type') != 'warehouse',
@@ -195,6 +195,27 @@
inactives.append(location)
cls.check_inactive(inactives)
+ @classmethod
+ def search_warehouse(cls, name, clause):
+ warehouse_child_locations = cls.search([
+ ('parent.type', '=', 'warehouse'),
+ ('type', '=', 'storage'),
+ ('parent', clause[1], clause[2]),
+ ])
+ found_warehouse_ids = []
+ storage_location_ids = []
+ for location in warehouse_child_locations:
+ storage_location_ids.append(location.id)
+ found_warehouse_ids.append(location.parent.id)
+ warehouse_location_ids = []
+ for location in cls.search([
+ ('parent', 'child_of', storage_location_ids),
+ ]):
+ if (location.warehouse and location.warehouse.id in
+ found_warehouse_ids):
+ warehouse_location_ids.append(location.id)
+ return [('id', 'in', warehouse_location_ids)]
+
def check_type_for_moves(self):
""" Check locations with moves have types compatible with moves. """
invalid_move_types = ['warehouse', 'view']

1
series
View File

@ -10,5 +10,6 @@ issue4506.diff # [account_invoice] Add credit invoices keyword from account.invo
issue4030.diff # [analytic_account] Not selected root accounts in analytic account lines
issue4482.diff # [stock] stock inventory misses company access rule
search_warehouse.diff #[stock] search function for warehouse.
stock_consignment_create_invoice_lines_on_move_done.diff # [stock_consignment] Task #034628: stock_consignment only create invoice lines on move done
domain_validation_warning.diff # [trytond] Increase the verbosity of domain_validation_error message