Lots Management
This commit is contained in:
@@ -2294,12 +2294,13 @@ class LotQt(
|
||||
# OpenPosition = Pool().get('open.position')
|
||||
# OpenPosition.create_from_purchase_line(pl)
|
||||
|
||||
@classmethod
|
||||
@classmethod
|
||||
def getQuery(cls, purchase=None, sale=None, shipment=None, type=None,
|
||||
state=None, qttype=None, supplier=None, client=None, ps=None,
|
||||
lot_status=None, group=None, product=None, location=None,
|
||||
origin=None, finished=False, shipping_status=None, asof=None,
|
||||
todate=None, dimension=None, strategy=None):
|
||||
todate=None, dimension=None, strategy=None, vessel=None,
|
||||
reference=None):
|
||||
pool = Pool()
|
||||
LotQt = pool.get('lot.qt')
|
||||
lqt = LotQt.__table__()
|
||||
@@ -2385,6 +2386,22 @@ class LotQt(
|
||||
elif ps == 'S':
|
||||
return sale_dimension
|
||||
return purchase_dimension | sale_dimension
|
||||
|
||||
def reference_filter():
|
||||
if not reference:
|
||||
return None
|
||||
pattern = '%%%s%%' % reference
|
||||
purchase_reference = (
|
||||
pu.reference.ilike(pattern)
|
||||
| pu.our_reference.ilike(pattern))
|
||||
sale_reference = (
|
||||
sa.reference.ilike(pattern)
|
||||
| sa.our_reference.ilike(pattern))
|
||||
if ps == 'P':
|
||||
return purchase_reference
|
||||
elif ps == 'S':
|
||||
return sale_reference
|
||||
return purchase_reference | sale_reference
|
||||
|
||||
wh = ((lqt.lot_quantity > 0) & ((lp.lot_type == 'virtual') | (ls.lot_type == 'virtual')))
|
||||
|
||||
@@ -2403,10 +2420,12 @@ class LotQt(
|
||||
wh &= (sa.id == sale)
|
||||
if state != 'all':
|
||||
wh &= (lqt.lot_av == state)
|
||||
if shipment:
|
||||
wh &= (lqt.lot_shipment_in == shipment)
|
||||
if product:
|
||||
wh &= (lqt.lot_product == product)
|
||||
if shipment:
|
||||
wh &= (lqt.lot_shipment_in == shipment)
|
||||
if vessel:
|
||||
wh &= (si.vessel == vessel)
|
||||
if product:
|
||||
wh &= (lqt.lot_product == product)
|
||||
if location:
|
||||
wh &= (Case((lqt.lot_shipment_in > 0, si.to_location),else_=Case((lqt.lot_shipment_internal > 0, sin.to_location),else_=pu.to_location)) == location)
|
||||
date_clause = date_filter(pu.purchase_date, sa.sale_date)
|
||||
@@ -2415,6 +2434,9 @@ class LotQt(
|
||||
dimension_clause = dimension_filter(pu.id, sa.id)
|
||||
if dimension_clause is not None:
|
||||
wh &= dimension_clause
|
||||
reference_clause = reference_filter()
|
||||
if reference_clause is not None:
|
||||
wh &= reference_clause
|
||||
if strategy:
|
||||
purchase_strategy = Exists(pstr.select(
|
||||
pstr.id,
|
||||
@@ -2569,10 +2591,12 @@ class LotQt(
|
||||
wh2 &= (sa.id == sale)
|
||||
if state != 'all':
|
||||
wh2 &= (lp.lot_av == state)
|
||||
if shipment:
|
||||
wh2 &= (lp.lot_shipment_in == shipment)
|
||||
if product:
|
||||
wh2 &= (lp.lot_product == product)
|
||||
if shipment:
|
||||
wh2 &= (lp.lot_shipment_in == shipment)
|
||||
if vessel:
|
||||
wh2 &= (si.vessel == vessel)
|
||||
if product:
|
||||
wh2 &= (lp.lot_product == product)
|
||||
if location:
|
||||
wh2 &= (Case((lp.lot_shipment_in > 0, si.to_location), else_=Case((lp.lot_shipment_internal > 0, sin.to_location), else_=pu.to_location)) == location)
|
||||
date_clause = date_filter(pu.purchase_date, sa.sale_date)
|
||||
@@ -2581,6 +2605,9 @@ class LotQt(
|
||||
dimension_clause = dimension_filter(pu.id, sa.id)
|
||||
if dimension_clause is not None:
|
||||
wh2 &= dimension_clause
|
||||
reference_clause = reference_filter()
|
||||
if reference_clause is not None:
|
||||
wh2 &= reference_clause
|
||||
if strategy:
|
||||
purchase_strategy = Exists(pstr.select(
|
||||
pstr.id,
|
||||
@@ -3215,8 +3242,10 @@ class LotReport(
|
||||
LotQT = Pool().get('lot.qt')
|
||||
purchase = context.get('purchase')
|
||||
sale = context.get('sale')
|
||||
shipment = context.get('shipment')
|
||||
product = context.get('product')
|
||||
shipment = context.get('shipment')
|
||||
vessel = context.get('vessel')
|
||||
reference = context.get('reference')
|
||||
product = context.get('product')
|
||||
location = context.get('location')
|
||||
type = context.get('type')
|
||||
state = context.get('state')
|
||||
@@ -3259,7 +3288,9 @@ class LotReport(
|
||||
asof=asof,
|
||||
todate=todate,
|
||||
dimension=dimension,
|
||||
strategy=strategy)
|
||||
strategy=strategy,
|
||||
vessel=vessel,
|
||||
reference=reference)
|
||||
return query
|
||||
|
||||
@classmethod
|
||||
@@ -3308,8 +3339,10 @@ class LotContext(ModelView):
|
||||
purchase = fields.Many2One('purchase.purchase', "Purchase")
|
||||
supplier = fields.Many2One('party.party', "Supplier")
|
||||
client = fields.Many2One('party.party', "Client")
|
||||
reference = fields.Char("Reference")
|
||||
sale = fields.Many2One('sale.sale', "Sale")
|
||||
shipment = fields.Many2One('stock.shipment.in', "Shipment")
|
||||
vessel = fields.Many2One('trade.vessel', "Vessel")
|
||||
dimension = fields.Many2One('analytic.dimension.value', "Dimension")
|
||||
strategy = fields.Many2One('mtm.strategy', "Strategy")
|
||||
product = fields.Many2One('product.product',"Product")
|
||||
@@ -3407,7 +3440,8 @@ class LotContext(ModelView):
|
||||
fields_names = fields_names.copy() if fields_names is not None else []
|
||||
for field_name in [
|
||||
'purchase', 'sale', 'shipment', 'supplier', 'client',
|
||||
'dimension', 'strategy', 'product', 'location', 'type',
|
||||
'reference', 'vessel', 'dimension', 'strategy', 'product',
|
||||
'location', 'type',
|
||||
'shipping_status', 'ps', 'state', 'wh', 'mode', 'group',
|
||||
'origin', 'finished', 'asof', 'todate']:
|
||||
if field_name not in fields_names:
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
|
||||
<label name="sale"/>
|
||||
<field name="sale"/>
|
||||
|
||||
<label name="reference"/>
|
||||
<field name="reference"/>
|
||||
</group>
|
||||
|
||||
<group id="lot_filters_product" string="Product & Logistics"
|
||||
@@ -57,5 +60,11 @@
|
||||
|
||||
<label name="origin"/>
|
||||
<field name="origin"/>
|
||||
|
||||
<label name="shipment"/>
|
||||
<field name="shipment"/>
|
||||
|
||||
<label name="vessel"/>
|
||||
<field name="vessel"/>
|
||||
</group>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user