diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index 749868c..59538bf 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -145,3 +145,4 @@ from . import invoice_payment from . import document from . import payment_matching from . import create_invoice_payment +from . import report_stock_card diff --git a/netforce_clinic/models/report_stock_card.py b/netforce_clinic/models/report_stock_card.py new file mode 100644 index 0000000..c06117b --- /dev/null +++ b/netforce_clinic/models/report_stock_card.py @@ -0,0 +1,81 @@ +from netforce.model import Model, get_model +from netforce.access import get_active_company + +class ReportStockCard(Model): + _inherit="report.stock.card" + + def get_report_data(self,ids,context={}): + company=get_model("company").browse(get_active_company()) + defaults=self.default_get(context=context) + location_id=defaults.get("location_id") + date_from=defaults.get('date_from') + date_to=defaults.get('date_to') + #product_id=defaults.get('product_id') + if not ids and not location_id: + return { + 'date_from': date_from, + 'date_to': date_to, + 'company_name': company.name, + } + data={ + 'loc_view': False, + } + if ids: + obj=self.browse(ids)[0] + location=obj.location_id + loc_view_id=location.id + if location.type=='view': + data.update({ + 'loc_view': True, + 'date_from': obj.date_from, + 'date_to': obj.date_to, + 'company_name': company.name, + }) + child_ids=get_model('stock.location').search([['parent_id','=',location.id]]) + locs={} + for child_id in child_ids: + obj.write({ + 'location_id': child_id, + }) + groups=super().get_report_data(ids,context)['groups'] + for group in groups: + location_id=group['location_id'] + locs.setdefault(location_id,{ + 'total_in_amount': 0, + 'total_in_qty': 0, + 'total_in_qty2': 0, + 'total_out_amount': 0, + 'total_out_qty': 0, + 'total_out_qty2': 0, + }) + locs[location_id]['total_in_amount']+=group['total_in_amount'] + locs[location_id]['total_in_qty']+=group['total_in_qty'] + locs[location_id]['total_in_qty2']+=group['total_in_qty2'] + locs[location_id]['total_out_amount']+=group['total_out_amount'] + locs[location_id]['total_out_qty']+=group['total_out_qty'] + locs[location_id]['total_out_qty2']+=group['total_out_qty2'] + lines=[] + for loc_id,vals in locs.items(): + vals['total_bl_qty']=vals['total_in_qty']-vals['total_out_qty'] + vals['total_bl_amount']=vals['total_in_amount']-vals['total_out_amount'] + vals['total_bl_qty2']=vals['total_in_qty2']-vals['total_out_qty2'] + location=get_model('stock.location').browse(loc_id) + vals.update({ + 'loc_id': loc_id, + 'loc_name': location.name, + }) + lines.append(vals) + obj.write({ + 'location_id': loc_view_id, + }) + data.update({ + 'lines': lines, + 'show_qty2': True, + }) + else: + data.update(super().get_report_data(ids,context)) + else: + data.update(super().get_report_data(ids,context)) + return data + +ReportStockCard.register() diff --git a/netforce_clinic/templates/report_stock_card.hbs b/netforce_clinic/templates/report_stock_card.hbs new file mode 100644 index 0000000..514551e --- /dev/null +++ b/netforce_clinic/templates/report_stock_card.hbs @@ -0,0 +1,264 @@ +
+

+ Stock Card +

+

+ {{company_name}} +

+

+ From {{date_from}} to {{date_to}} +

+
+{{#if loc_view}} + + + + + + + + + + + + {{#if show_qty2}} + + {{/if}} + + + {{#if show_qty2}} + + {{/if}} + + + {{#if show_qty2}} + + {{/if}} + + + + {{#each lines}} + + + + + + + + + + + + + {{/each}} + + + +
LocationInOutBalance
+ Qty + + Amount + + Secondary Qty + + Qty + + Amount + + Secondary Qty + + Qty + + Amount + + Secondary Qty +
+ + {{loc_name}} + + + {{currency total_in_qty}} + + {{currency total_in_amount}} + + {{currency total_in_qty2}} + + {{currency total_out_qty}} + + {{currency total_out_amount}} + + {{currency total_out_qty2}} + + {{currency total_bl_qty}} + + {{currency total_bl_amount}} + + {{currency total_bl_qty2}} +
+{{else}} + + + + + + + + + + + + + + + + {{#if show_qty2}} + + {{/if}} + + + + {{#if show_qty2}} + + {{/if}} + + + + {{#if show_qty2}} + + {{/if}} + + + + {{#each groups context=context}} + + + + {{#each lines context=context}} + + + + + + + + + {{#if ../../show_qty2}} + + {{/if}} + + + + {{#if ../../show_qty2}} + + {{/if}} + + + + {{#if ../../show_qty2}} + + {{/if}} + + {{/each}} + + + + + + + + + {{#if ../show_qty2}} + + {{/if}} + + + + {{#if ../show_qty2}} + + {{/if}} + + + + + {{/each}} + +
DateRefLot / Serial NumberInvoiceInOutBalance
+ Qty + + Unit Price + + Amount + + Secondary Qty + + Qty + + Unit Price + + Amount + + Secondary Qty + + Qty + + Cost Price + + Cost Amount + + Secondary Qty +
+ {{product_name}} + @ {{location_name}} +
+ {{date}} + + {{view "link" string=ref action="view_stock_transaction" active_id=id context=context}} + + {{view "link" string=lot_num action="stock_lot" action_options="mode=form" active_id=lot_id context=context}} + + {{view "link" string=invoice_num action="view_invoice" active_id=invoice_id context=context}} + + {{currency in_qty}} + + {{currency in_unit_price}} + + {{currency in_amount}} + + {{currency in_qty2}} + + {{currency out_qty}} + + {{currency out_unit_price}} + + {{currency out_amount}} + + {{currency out_qty2}} + + {{currency bal_qty}} + + {{currency bal_cost_price}} + + {{currency bal_cost_amount}} + + {{currency bal_qty2}} +
+ + Total + + + + {{currency total_in_qty}} + + + {{currency total_in_amount}} + + {{currency total_in_qty2}} + + {{currency total_out_qty}} + + + {{currency total_out_amount}} + + {{currency total_out_qty2}} +
+{{/if}}