sequence
parent
f1549b2536
commit
b340622e9e
|
@ -0,0 +1,5 @@
|
||||||
|
<inherit model="sequence" inherit="sequence_list">
|
||||||
|
<field name="company_id" position="after">
|
||||||
|
<field name="branch_id"/>
|
||||||
|
</field>
|
||||||
|
</inherit>
|
|
@ -35,10 +35,10 @@ class Dialyzer(Model):
|
||||||
|
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
while 1:
|
while 1:
|
||||||
seq_name='Clinic Dialyzer'
|
seq_type='clinic_dlz'
|
||||||
seq_id=get_model("sequence").find_sequence(name=seq_name)
|
seq_id=get_model("sequence").find_sequence(type=seq_type)
|
||||||
if not seq_id:
|
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)
|
num=get_model("sequence").get_next_number(seq_id,context=context)
|
||||||
if not num:
|
if not num:
|
||||||
return None
|
return None
|
||||||
|
@ -175,7 +175,9 @@ class Dialyzer(Model):
|
||||||
pick.set_done([pick_id])
|
pick.set_done([pick_id])
|
||||||
number=obj.number.replace("/","")
|
number=obj.number.replace("/","")
|
||||||
if not number:
|
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({
|
obj.write({
|
||||||
"number": number,
|
"number": number,
|
||||||
"state": "active",
|
"state": "active",
|
||||||
|
|
|
@ -184,7 +184,8 @@ class HDCase(Model):
|
||||||
|
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
while 1:
|
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)
|
num=get_model("sequence").get_next_number(seq_id,context=context)
|
||||||
if not num:
|
if not num:
|
||||||
return None
|
return None
|
||||||
|
@ -715,7 +716,8 @@ class HDCase(Model):
|
||||||
'state': 'in_progress',
|
'state': 'in_progress',
|
||||||
}
|
}
|
||||||
if obj.number=='/':
|
if obj.number=='/':
|
||||||
number=self._get_number()
|
context['branch_id']=obj.branch_id.id
|
||||||
|
number=self._get_number(context=context)
|
||||||
vals['number']=number
|
vals['number']=number
|
||||||
|
|
||||||
# update start time
|
# update start time
|
||||||
|
|
|
@ -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):
|
class Sequence(Model):
|
||||||
_inherit="sequence"
|
_inherit="sequence"
|
||||||
_fields={
|
_fields={
|
||||||
'fax': fields.Char("Fax"),
|
|
||||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
'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()
|
Sequence.register()
|
||||||
|
|
|
@ -170,7 +170,8 @@ class Staff(Model):
|
||||||
|
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
while 1:
|
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:
|
if not seq_id:
|
||||||
return "/"
|
return "/"
|
||||||
num=get_model("sequence").get_next_number(seq_id,context=context)
|
num=get_model("sequence").get_next_number(seq_id,context=context)
|
||||||
|
|
|
@ -55,10 +55,10 @@ class Visit(Model):
|
||||||
|
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
while 1:
|
while 1:
|
||||||
seq_name='Clinic Visit'
|
seq_type='clinic_visit'
|
||||||
seq_id=get_model("sequence").find_sequence(name=seq_name)
|
seq_id=get_model("sequence").find_sequence(type=seq_type)
|
||||||
if not seq_id:
|
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)
|
num=get_model("sequence").get_next_number(seq_id,context=context)
|
||||||
if not num:
|
if not num:
|
||||||
return None
|
return None
|
||||||
|
@ -153,7 +153,9 @@ class Visit(Model):
|
||||||
raise Exception("Can not confirm visit %s: datenow is %s"%(obj.number or "", datenow))
|
raise Exception("Can not confirm visit %s: datenow is %s"%(obj.number or "", datenow))
|
||||||
number=obj.number
|
number=obj.number
|
||||||
if number=="/" or not 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={
|
vals={
|
||||||
'number': number,
|
'number': number,
|
||||||
'state': 'confirmed',
|
'state': 'confirmed',
|
||||||
|
@ -439,7 +441,9 @@ class Visit(Model):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
if obj.number != '/' or obj.state not in ('draft','pending'):
|
if obj.number != '/' or obj.state not in ('draft','pending'):
|
||||||
return
|
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({
|
obj.write({
|
||||||
'number': number,
|
'number': number,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue