conv_bal
watcha.h 2015-03-17 22:51:56 +07:00
parent f1549b2536
commit b340622e9e
6 changed files with 98 additions and 14 deletions

View File

@ -0,0 +1,5 @@
<inherit model="sequence" inherit="sequence_list">
<field name="company_id" position="after">
<field name="branch_id"/>
</field>
</inherit>

View File

@ -35,10 +35,10 @@ class Dialyzer(Model):
def _get_number(self,context={}):
while 1:
seq_name='Clinic Dialyzer'
seq_id=get_model("sequence").find_sequence(name=seq_name)
seq_type='clinic_dlz'
seq_id=get_model("sequence").find_sequence(type=seq_type)
if not seq_id:
raise Exception("Can not found sequence %s"%seq_name)
raise Exception("Can not found sequence %s"%seq_type)
num=get_model("sequence").get_next_number(seq_id,context=context)
if not num:
return None
@ -175,7 +175,9 @@ class Dialyzer(Model):
pick.set_done([pick_id])
number=obj.number.replace("/","")
if not number:
number=self._get_number(context)
department=obj.department_id
context['branch_id']=department.branch_id.id
number=self._get_number(context=context)
obj.write({
"number": number,
"state": "active",

View File

@ -184,7 +184,8 @@ class HDCase(Model):
def _get_number(self,context={}):
while 1:
seq_id=get_model("sequence").find_sequence(name="Clinic HD Case")
#seq_id=get_model("sequence").find_sequence(name="Clinic HD Case")
seq_id=get_model("sequence").find_sequence(type="clinic_hdcase")
num=get_model("sequence").get_next_number(seq_id,context=context)
if not num:
return None
@ -715,7 +716,8 @@ class HDCase(Model):
'state': 'in_progress',
}
if obj.number=='/':
number=self._get_number()
context['branch_id']=obj.branch_id.id
number=self._get_number(context=context)
vals['number']=number
# update start time

View File

@ -1,10 +1,80 @@
from netforce.model import Model, fields
from netforce.model import Model, fields, get_model
from netforce.access import get_active_company, get_active_user
class Sequence(Model):
_inherit="sequence"
_fields={
'fax': fields.Char("Fax"),
'branch_id': fields.Many2One("clinic.branch","Branch"),
"type": fields.Selection([
["cust_invoice","Customer Invoice"],
["supp_invoice","Supplier Invoice"],
["cust_credit","Customer Credit Note"],
["supp_credit","Supplier Credit Note"],
["cust_debit","Customer Debit Note"],
["supp_debit","Supplier Debit Note"],
["pay_in","Incoming Payment"],
["pay_out","Outgoing Payment"],
["transfer","Transfer"],
["tax_no","Tax No"],
["wht_no","WHT No"],
["account_move","Journal Entry"],
["pick_in","Goods Receipt"],
["pick_internal","Goods Transfer"],
["pick_out","Goods Issue"],
["stock_count","Stock Count"],
["stock_lot","Lot / Serial Number"],
["stock_container","Container"],
["shipping_rates","Shipping Rates"],
["sale_quot","Sales Quotations"],
["sale_order","Sales Order"],
["ecom_sale_order","Ecommerce Sales Order"],
["purchase_order","Purchase Order"],
["purchase_request","Purchase Request"],
["pos_closure","POS Register Closure"],
["production","Production Order"],
["bom","Bill of Material"],
["service_item","Service Item"],
["job","Service Order"],
["service_contract","Service Contract"],
["employee","Employee"],
["payrun","Payrun"],
["leave_request","Leave Request"],
["expense","Expense Claim"],
["fixed_asset","Fixed Asset"],
["claim","Product Claims"],
["borrow","Product Borrowings"],
["clinic_patient","Patient"],
["clinic_staff","Staff"],
["clinic_visit","Visit"],
["clinic_hdcase","HD Case"],
["clinic_dlz","Dialyzer"],
["clinic_rdshop","RD Shop"],
["other","Other"]],"Type",required=True,search=True),
}
def find_sequence(self,type=None,name=None,context={}):
if type and name:
dom=[["type","=",type],["name","=",name]]
elif type:
dom=[["type","=",type]]
elif name:
dom=[["name","=",name]]
company_id=get_active_company()
comp_dom=dom+[["company_id","=",company_id]]
user_id=get_active_user()
user=get_model('base.user').browse(user_id)
dpt=user.department_id
if dpt:
branch_id=dpt.branch_id.id
comp_dom=comp_dom+[["branch_id","=",branch_id]]
elif context.get('branch_id'):
comp_dom=comp_dom+[["branch_id","=",context['branch_id']]]
res=self.search(comp_dom,order="id")
if res:
return res[0]
res=self.search(dom,order="id")
if res:
return res[0]
return None
Sequence.register()

View File

@ -170,7 +170,8 @@ class Staff(Model):
def _get_number(self,context={}):
while 1:
seq_id=get_model("sequence").find_sequence(name="Clinic Staff")
seq_type='clinic_staff'
seq_id=get_model("sequence").find_sequence(type=seq_type)
if not seq_id:
return "/"
num=get_model("sequence").get_next_number(seq_id,context=context)

View File

@ -55,10 +55,10 @@ class Visit(Model):
def _get_number(self,context={}):
while 1:
seq_name='Clinic Visit'
seq_id=get_model("sequence").find_sequence(name=seq_name)
seq_type='clinic_visit'
seq_id=get_model("sequence").find_sequence(type=seq_type)
if not seq_id:
raise Exception("Can not found sequence %s"%seq_name)
raise Exception("Can not found sequence %s"%seq_type)
num=get_model("sequence").get_next_number(seq_id,context=context)
if not num:
return None
@ -153,7 +153,9 @@ class Visit(Model):
raise Exception("Can not confirm visit %s: datenow is %s"%(obj.number or "", datenow))
number=obj.number
if number=="/" or not number:
number=self._get_number(context)
branch=obj.department_id.branch_id
context['branch_id']=branch.id
number=self._get_number(context=context)
vals={
'number': number,
'state': 'confirmed',
@ -439,7 +441,9 @@ class Visit(Model):
obj=self.browse(ids)[0]
if obj.number != '/' or obj.state not in ('draft','pending'):
return
number=self._get_number(context)
branch=obj.department_id.branch_id
context['branch_id']=branch.id
number=self._get_number(context=context)
obj.write({
'number': number,
})