add option for search quantity in stock all warehouse or one

This commit is contained in:
wilson gomez 2021-12-09 09:02:18 -05:00
parent 890e705ffe
commit 8050a6cdbf
2 changed files with 13 additions and 4 deletions

View file

@ -11,6 +11,7 @@ from trytond.transaction import Transaction
class Configuration(metaclass=PoolMeta):
__name__ = 'purchase.configuration'
reference_required = fields.Boolean('Reference Required')
all_warehouse = fields.Boolean('All Warehouse', 'See quantity in all warehouse')
class Purchase(metaclass=PoolMeta):
@ -72,10 +73,15 @@ class Line(metaclass=PoolMeta):
if self.product:
context = {'stock_date_end': date.today()}
Location = Pool().get('stock.location')
locations = Location.search([
('type', '=', 'warehouse')
])
location_ids = [l.storage_location.id for l in locations if l.storage_location]
Configuration = Pool().get('purchase.configuration')
configuration = Configuration(1)
if configuration.all_warehouse:
locations = Location.search([
('type', '=', 'warehouse')
])
location_ids = [l.storage_location.id for l in locations if l.storage_location]
else:
location_ids = [self.purchase.warehouse.storage_location.id]
product_ids = [self.product.id]
quantity = 0
with Transaction().set_context(context):

View file

@ -5,5 +5,8 @@ this repository contains the full copyright notices and license terms. -->
<xpath expr="/form/field[@name='purchase_process_after']" position="after">
<label name="reference_required"/>
<field name="reference_required"/>
<label name="all_warehouse"/>
<field name="all_warehouse"/>
</xpath>
</data>