2015-03-17 15:51:56 +00:00
|
|
|
from netforce.model import Model, fields, get_model
|
|
|
|
from netforce.access import get_active_company, get_active_user
|
2015-03-17 09:29:34 +00:00
|
|
|
|
|
|
|
class Sequence(Model):
|
|
|
|
_inherit="sequence"
|
|
|
|
_fields={
|
|
|
|
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
2015-03-17 15:51:56 +00:00
|
|
|
"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"],
|
2015-03-31 04:48:41 +00:00
|
|
|
["clinic_rdshop_credit","RD Shop Credit"],
|
|
|
|
["clinic_rdshop_cash","RD Shop Cash"],
|
2015-03-31 08:00:45 +00:00
|
|
|
["clinic_invoice_noclaim","Invoice No Claim"],
|
2015-03-17 15:51:56 +00:00
|
|
|
["other","Other"]],"Type",required=True,search=True),
|
2015-03-17 09:29:34 +00:00
|
|
|
}
|
|
|
|
|
2015-03-17 15:51:56 +00:00
|
|
|
def find_sequence(self,type=None,name=None,context={}):
|
2015-05-11 03:54:36 +00:00
|
|
|
print('name ', name, type, context)
|
2015-03-17 15:51:56 +00:00
|
|
|
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
|
2015-03-18 01:39:03 +00:00
|
|
|
branch=user.branch_id
|
2015-10-15 04:31:59 +00:00
|
|
|
if context.get('branch_id'):
|
|
|
|
comp_dom=comp_dom+[["branch_id","=",context['branch_id']]]
|
|
|
|
elif dpt:
|
2015-03-17 15:51:56 +00:00
|
|
|
branch_id=dpt.branch_id.id
|
|
|
|
comp_dom=comp_dom+[["branch_id","=",branch_id]]
|
2015-03-18 01:39:03 +00:00
|
|
|
elif branch:
|
|
|
|
branch_id=branch.id
|
|
|
|
comp_dom=comp_dom+[["branch_id","=",branch_id]]
|
2015-10-15 04:31:59 +00:00
|
|
|
#elif context.get('branch_id'):
|
|
|
|
#comp_dom=comp_dom+[["branch_id","=",context['branch_id']]]
|
2015-03-18 01:39:03 +00:00
|
|
|
print('com_dom ', comp_dom)
|
2015-03-17 15:51:56 +00:00
|
|
|
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
|
|
|
|
|
2015-03-17 09:29:34 +00:00
|
|
|
Sequence.register()
|