Need to run special number of invoice & receipt from rd shop.

conv_bal
watcha.h 2015-03-31 11:48:41 +07:00
parent ebb102e602
commit 649f052e0a
4 changed files with 42 additions and 10 deletions

View File

@ -49,6 +49,8 @@ class Sequence(Model):
["clinic_hdcase","HD Case"], ["clinic_hdcase","HD Case"],
["clinic_dlz","Dialyzer"], ["clinic_dlz","Dialyzer"],
["clinic_rdshop","RD Shop"], ["clinic_rdshop","RD Shop"],
["clinic_rdshop_credit","RD Shop Credit"],
["clinic_rdshop_cash","RD Shop Cash"],
["other","Other"]],"Type",required=True,search=True), ["other","Other"]],"Type",required=True,search=True),
} }

View File

@ -118,6 +118,34 @@ class Shop(Model):
return num return num
get_model("sequence").increment_number(seq_id,context=context) 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={}): def _get_branch(self,context={}):
res=get_model('select.company').get_select() res=get_model('select.company').get_select()
if res: if res:
@ -290,7 +318,10 @@ class Shop(Model):
cst=get_model('clinic.setting').browse(1) cst=get_model('clinic.setting').browse(1)
prod_acc=cst.get_product_account prod_acc=cst.get_product_account
partner=obj.contact_id partner=obj.contact_id
context['branch_id']=obj.branch_id.id
number=self._get_credit_number(context=context),
vals={ vals={
'number': number,
"type": "out", "type": "out",
"inv_type": "invoice", "inv_type": "invoice",
"tax_type": "tax_in", "tax_type": "tax_in",
@ -421,7 +452,10 @@ class Shop(Model):
if not income_account_id: if not income_account_id:
raise Exception("No Income Account") raise Exception("No Income Account")
company_id=get_active_company() company_id=get_active_company()
context['branch_id']=obj.branch_id.id
number=self._get_cash_number(context=context),
vals={ vals={
'number': number,
"partner_id": partner.id, "partner_id": partner.id,
"company_id": company_id, "company_id": company_id,
"type": "in", "type": "in",

View File

@ -28,16 +28,12 @@
<tr> <tr>
<td style="width:10%">{{date}}</td> <td style="width:10%">{{date}}</td>
<td style="width:20%">{{pname}}</td> <td style="width:20%">{{pname}}</td>
<td>{{pm_number}}</td> <td>
{{#ifeq ptype "credit"}} {{view "link" string=pm_number action="payment" action_options="mode=form" active_id=pm_id}}
<td> </td>
{{view "link" string=inv_number action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}} <td>
</td> {{view "link" string=inv_number action="cust_invoice" action_options="form_view_xml&cust_invoice_form&mode=form" active_id=inv_id}}
{{else}} </td>
<td>
{{view "link" string=pm_number action="payment" action_options="mode=form" active_id=pm_id}}
</td>
{{/if}}
<td>{{mdc_name}}</td> <td>{{mdc_name}}</td>
<td>{{currency fee zero=""}}</td> <td>{{currency fee zero=""}}</td>
<td>{{currency mdc zero=""}}</td> <td>{{currency mdc zero=""}}</td>