diff --git a/netforce_clinic/models/sequence.py b/netforce_clinic/models/sequence.py index e91c818..e8173eb 100644 --- a/netforce_clinic/models/sequence.py +++ b/netforce_clinic/models/sequence.py @@ -49,6 +49,8 @@ class Sequence(Model): ["clinic_hdcase","HD Case"], ["clinic_dlz","Dialyzer"], ["clinic_rdshop","RD Shop"], + ["clinic_rdshop_credit","RD Shop Credit"], + ["clinic_rdshop_cash","RD Shop Cash"], ["other","Other"]],"Type",required=True,search=True), } diff --git a/netforce_clinic/models/shop.py b/netforce_clinic/models/shop.py index a73a922..3e987fe 100644 --- a/netforce_clinic/models/shop.py +++ b/netforce_clinic/models/shop.py @@ -118,6 +118,34 @@ class Shop(Model): return num get_model("sequence").increment_number(seq_id,context=context) + def _get_credit_number(self,context={}): + while 1: + seq_id=get_model("sequence").find_sequence(type="clinic_rdshop_credit",context=context) + num=get_model("sequence").get_next_number(seq_id,context=context) + if not num: + return None + user_id=get_active_user() + set_active_user(1) + res=self.search([["number","=",num]]) + set_active_user(user_id) + if not res: + return num + get_model("sequence").increment_number(seq_id,context=context) + + def _get_cash_number(self,context={}): + while 1: + seq_id=get_model("sequence").find_sequence(type="clinic_rdshop_cash",context=context) + num=get_model("sequence").get_next_number(seq_id,context=context) + if not num: + return None + user_id=get_active_user() + set_active_user(1) + res=self.search([["number","=",num]]) + set_active_user(user_id) + if not res: + return num + get_model("sequence").increment_number(seq_id,context=context) + def _get_branch(self,context={}): res=get_model('select.company').get_select() if res: @@ -290,7 +318,10 @@ class Shop(Model): cst=get_model('clinic.setting').browse(1) prod_acc=cst.get_product_account partner=obj.contact_id + context['branch_id']=obj.branch_id.id + number=self._get_credit_number(context=context), vals={ + 'number': number, "type": "out", "inv_type": "invoice", "tax_type": "tax_in", @@ -421,7 +452,10 @@ class Shop(Model): if not income_account_id: raise Exception("No Income Account") company_id=get_active_company() + context['branch_id']=obj.branch_id.id + number=self._get_cash_number(context=context), vals={ + 'number': number, "partner_id": partner.id, "company_id": company_id, "type": "in", diff --git a/netforce_clinic/reports/report_shop.xlsx b/netforce_clinic/reports/report_shop.xlsx index 2c3e1b2..4d1f7dc 100644 Binary files a/netforce_clinic/reports/report_shop.xlsx and b/netforce_clinic/reports/report_shop.xlsx differ diff --git a/netforce_clinic/templates/report_shop.hbs b/netforce_clinic/templates/report_shop.hbs index 01f190a..2aab40e 100644 --- a/netforce_clinic/templates/report_shop.hbs +++ b/netforce_clinic/templates/report_shop.hbs @@ -28,16 +28,12 @@ {{date}} {{pname}} - {{pm_number}} - {{#ifeq ptype "credit"}} - - {{view "link" string=inv_number action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}} - - {{else}} - - {{view "link" string=pm_number action="payment" action_options="mode=form" active_id=pm_id}} - - {{/if}} + + {{view "link" string=pm_number action="payment" action_options="mode=form" active_id=pm_id}} + + + {{view "link" string=inv_number action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}} + {{mdc_name}} {{currency fee zero=""}} {{currency mdc zero=""}}