From e7b7d18ed67a787d00546a1128031d0054a939fd Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Tue, 31 Mar 2015 15:00:45 +0700 Subject: [PATCH] special running number of invoice no claim from hd case. --- netforce_clinic/models/hd_case.py | 16 ++++++++++++++++ netforce_clinic/models/sequence.py | 1 + 2 files changed, 17 insertions(+) diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 1e36492..2ce1bb5 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -278,6 +278,20 @@ class HDCase(Model): return num 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={ "state": "draft", "date": lambda *a: time.strftime("%Y-%m-%d"), @@ -661,7 +675,9 @@ class HDCase(Model): partner=patient.partner_id if not partner: raise Exception("No contact for this patient %s"%obj.partner.name) + number=self._get_invoice_noclaim_number(context=context) vals={ + 'number': number, "type": "out", "inv_type": "invoice", "tax_type": "tax_in", diff --git a/netforce_clinic/models/sequence.py b/netforce_clinic/models/sequence.py index e8173eb..a0d9a00 100644 --- a/netforce_clinic/models/sequence.py +++ b/netforce_clinic/models/sequence.py @@ -51,6 +51,7 @@ class Sequence(Model): ["clinic_rdshop","RD Shop"], ["clinic_rdshop_credit","RD Shop Credit"], ["clinic_rdshop_cash","RD Shop Cash"], + ["clinic_invoice_noclaim","Invoice No Claim"], ["other","Other"]],"Type",required=True,search=True), }