Skip to content

Commit

Permalink
BAH-3657 | Refactor. Sale quotation when a product with mu… (#80)
Browse files Browse the repository at this point in the history
* [Karthi] | BAH-3657 | Refactor. Sale quotation when a product with multiple lot without expiry is added issue fixed.

* [Karthi] | BAH-3657 | Refactor. By Lot without expiration date logic has been updated and zero qty lot not show in selection in the view
  • Loading branch information
karthikeyansp91 authored Mar 11, 2024
1 parent 5a75845 commit 3b6019e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 12 additions & 7 deletions bahmni_sale/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,19 @@ def get_available_batch_details(self, product_id, sale_order):
('id', 'not in', already_used_batch_ids if already_used_batch_ids else False)]\
if len(already_used_batch_ids) > 0 else [('product_id','=', product_id.id if type(product_id) != list else product_id[0])]

for prodlot in stock_prod_lot.search(query, order='expiration_date asc'):
date_lenth = len(str(prodlot.expiration_date))
if len(str(prodlot.expiration_date)) > 20:
formatted_ts = datetime.strptime(str(prodlot.expiration_date), "%Y-%m-%d %H:%M:%S.%f").strftime("%Y-%m-%d %H:%M:%S")
else:
formatted_ts = datetime.strptime(str(prodlot.expiration_date), "%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%d %H:%M:%S")
if(formatted_ts and datetime.strptime(str(formatted_ts), DTF) > datetime.today()):
for prodlot in stock_prod_lot.search(query, order='expiration_date asc'):
if prodlot.expiration_date and prodlot.product_qty::
date_lenth = len(str(prodlot.expiration_date))
if len(str(prodlot.expiration_date)) > 20:
formatted_ts = datetime.strptime(str(prodlot.expiration_date), "%Y-%m-%d %H:%M:%S.%f").strftime("%Y-%m-%d %H:%M:%S")
else:
formatted_ts = datetime.strptime(str(prodlot.expiration_date), "%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%d %H:%M:%S")
if(formatted_ts and datetime.strptime(str(formatted_ts), DTF) > datetime.today()):
return prodlot
elif prodlot.product_qty:
return prodlot
else:
pass
return None

def invoice_line_create(self, invoice_id, qty):
Expand Down
4 changes: 2 additions & 2 deletions bahmni_sale/views/sale_order_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@


<xpath expr="//field[@name='order_line']/tree/field[@name='qty_delivered']" position="after">
<field name="lot_id" domain="[('product_id','=',product_id),('expiration_date','&gt;', datetime.datetime.combine(context_today(), datetime.time(23,59,59)))]"/>
<field name="lot_id" domain="['|',('expiration_date','&gt;', datetime.datetime.combine(context_today(), datetime.time(23,59,59))),('expiration_date','=',False),('product_qty','>' ,0),('product_id','=',product_id)]"/>
<field name="expiry_date" force_save="1" readonly="1"/>
</xpath>
<xpath expr="//field[@name='order_line']/form/group/group/field[@name='price_unit']" position="after">
<field name="lot_id" domain="[('expiration_date','&gt;', datetime.datetime.combine(context_today(), datetime.time(23,59,59)))]"/>
<field name="lot_id" domain="['|',('expiration_date','&gt;', datetime.datetime.combine(context_today(), datetime.time(23,59,59))),('expiration_date','=',False),('product_qty','>' ,0),('product_id','=',product_id)]"/>
<field name="expiry_date" readonly="1"/>
</xpath>
<xpath expr="//field[@name='order_line']/tree/field[@name='product_id']" position="replace">
Expand Down

0 comments on commit 3b6019e

Please sign in to comment.