special running number of invoice no claim from hd case.

conv_bal
watcha.h 2015-03-31 15:00:45 +07:00
parent 649f052e0a
commit e7b7d18ed6
2 changed files with 17 additions and 0 deletions

View File

@ -278,6 +278,20 @@ class HDCase(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_invoice_noclaim_number(self,context={}):
while 1:
seq_id=get_model("sequence").find_sequence(type="clinic_invoice_noclaim")
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)
_defaults={ _defaults={
"state": "draft", "state": "draft",
"date": lambda *a: time.strftime("%Y-%m-%d"), "date": lambda *a: time.strftime("%Y-%m-%d"),
@ -661,7 +675,9 @@ class HDCase(Model):
partner=patient.partner_id partner=patient.partner_id
if not partner: if not partner:
raise Exception("No contact for this patient %s"%obj.partner.name) raise Exception("No contact for this patient %s"%obj.partner.name)
number=self._get_invoice_noclaim_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",

View File

@ -51,6 +51,7 @@ class Sequence(Model):
["clinic_rdshop","RD Shop"], ["clinic_rdshop","RD Shop"],
["clinic_rdshop_credit","RD Shop Credit"], ["clinic_rdshop_credit","RD Shop Credit"],
["clinic_rdshop_cash","RD Shop Cash"], ["clinic_rdshop_cash","RD Shop Cash"],
["clinic_invoice_noclaim","Invoice No Claim"],
["other","Other"]],"Type",required=True,search=True), ["other","Other"]],"Type",required=True,search=True),
} }