improve
parent
be291d21a2
commit
1a712b1203
|
@ -1,6 +1,7 @@
|
||||||
<inherit model="base.user" inherit="user_form">
|
<inherit model="base.user" inherit="user_form">
|
||||||
<field name="pin_code" position="after">
|
<field name="pin_code" position="after">
|
||||||
<field name="department_profile_id"/>
|
<field name="department_profile_id"/>
|
||||||
|
<field name="branch_id"/>
|
||||||
<field name="old_profile_id"/>
|
<field name="old_profile_id"/>
|
||||||
</field>
|
</field>
|
||||||
</inherit>
|
</inherit>
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import time
|
|
||||||
|
|
||||||
from netforce.model import Model, fields, get_model
|
from netforce.model import Model, fields, get_model
|
||||||
|
|
||||||
class AccountInvoice(Model):
|
class AccountInvoice(Model):
|
||||||
|
@ -10,5 +8,45 @@ class AccountInvoice(Model):
|
||||||
'patient_partner_id': fields.Many2One("partner","Patient",search=True),
|
'patient_partner_id': fields.Many2One("partner","Patient",search=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _get_number(self,context={}):
|
||||||
|
defaults=context.get("defaults")
|
||||||
|
if defaults: # XXX
|
||||||
|
type=defaults.get("type")
|
||||||
|
inv_type=defaults.get("inv_type")
|
||||||
|
else:
|
||||||
|
type=context.get("type")
|
||||||
|
inv_type=context.get("inv_type")
|
||||||
|
seq_type=None
|
||||||
|
if type=="out":
|
||||||
|
if inv_type in ("invoice","prepay"):
|
||||||
|
seq_type="cust_invoice"
|
||||||
|
elif inv_type=="credit":
|
||||||
|
seq_type="cust_credit"
|
||||||
|
elif inv_type=="debit":
|
||||||
|
seq_type="cust_debit"
|
||||||
|
elif type=="in":
|
||||||
|
if inv_type in ("invoice","prepay"):
|
||||||
|
seq_type="supp_invoice"
|
||||||
|
elif inv_type=="credit":
|
||||||
|
seq_type="supp_credit"
|
||||||
|
elif inv_type=="debit":
|
||||||
|
seq_type="supp_debit"
|
||||||
|
if not seq_type:
|
||||||
|
return
|
||||||
|
seq_id=get_model("sequence").find_sequence(type=seq_type,context=context)
|
||||||
|
if not seq_id:
|
||||||
|
return None
|
||||||
|
while 1:
|
||||||
|
num=get_model("sequence").get_next_number(seq_id,context=context)
|
||||||
|
res=self.search([["number","=",num]])
|
||||||
|
if not res:
|
||||||
|
return num
|
||||||
|
get_model("sequence").increment_number(seq_id,context=context)
|
||||||
|
|
||||||
|
_defaults={
|
||||||
|
"number": _get_number,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AccountInvoice.register()
|
AccountInvoice.register()
|
||||||
|
|
|
@ -4,8 +4,32 @@ class AccountPayment(Model):
|
||||||
_inherit="account.payment"
|
_inherit="account.payment"
|
||||||
_fields={
|
_fields={
|
||||||
'rd_cust': fields.Boolean("RD Customize"),
|
'rd_cust': fields.Boolean("RD Customize"),
|
||||||
|
'number': fields.Char("Number",required=True,search=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _get_number(self,context={}):
|
||||||
|
type=context.get("type")
|
||||||
|
if type=="in":
|
||||||
|
seq_type="pay_in"
|
||||||
|
elif type=="out":
|
||||||
|
seq_type="pay_out"
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
seq_id=get_model("sequence").find_sequence(type=seq_type,context=context) # force to use context
|
||||||
|
if not seq_id:
|
||||||
|
return None
|
||||||
|
while 1:
|
||||||
|
num=get_model("sequence").get_next_number(seq_id,context=context)
|
||||||
|
res=self.search([["number","=",num]])
|
||||||
|
if not res:
|
||||||
|
return num
|
||||||
|
get_model("sequence").increment_number(seq_id,context=context)
|
||||||
|
|
||||||
|
_defaults={
|
||||||
|
'number': _get_number,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def run_report(self,ids,context={}):
|
def run_report(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
hd_case_id=obj.related_id.id
|
hd_case_id=obj.related_id.id
|
||||||
|
|
|
@ -5,6 +5,7 @@ class User(Model):
|
||||||
_fields={
|
_fields={
|
||||||
'department_profile_id': fields.Many2One("clinic.department.profile","Department Profile"),
|
'department_profile_id': fields.Many2One("clinic.department.profile","Department Profile"),
|
||||||
'department_id': fields.Many2One("clinic.department","Current Department"),
|
'department_id': fields.Many2One("clinic.department","Current Department"),
|
||||||
|
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||||
'old_profile_id': fields.Many2One('profile', "Old Profile"),
|
'old_profile_id': fields.Many2One('profile', "Old Profile"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,11 @@ class Login(Model):
|
||||||
user_id=get_active_user()
|
user_id=get_active_user()
|
||||||
user=get_model('base.user').browse(user_id)
|
user=get_model('base.user').browse(user_id)
|
||||||
department=user.department_id
|
department=user.department_id
|
||||||
|
branch=user.branch_id
|
||||||
if department:
|
if department:
|
||||||
cookies['company_name']='%s (%s)'%(cookies['company_name'], department.name or "")
|
cookies['company_name']='%s (%s)'%(cookies['company_name'], department.name or "")
|
||||||
|
elif branch:
|
||||||
|
cookies['company_name']='%s (%s)'%(cookies['company_name'], branch.name or "")
|
||||||
return res
|
return res
|
||||||
|
|
||||||
Login.register()
|
Login.register()
|
||||||
|
|
|
@ -171,10 +171,12 @@ class SelectCompany(Model):
|
||||||
'profile_id': pf_id,
|
'profile_id': pf_id,
|
||||||
})
|
})
|
||||||
res=super().select(ids,context)
|
res=super().select(ids,context)
|
||||||
if department_name:
|
cookies=res.get("cookies")
|
||||||
cookies=res.get("cookies")
|
if cookies:
|
||||||
if cookies:
|
if department_name:
|
||||||
cookies['company_name']='%s (%s)'%(cookies['company_name'], department_name)
|
cookies['company_name']='%s (%s)'%(cookies['company_name'], department_name)
|
||||||
|
elif user.branch_id:
|
||||||
|
cookies['company_name']='%s (%s)'%(cookies['company_name'], user.branch_id.name or "")
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_select(self,context={}):
|
def get_select(self,context={}):
|
||||||
|
|
|
@ -64,11 +64,16 @@ class Sequence(Model):
|
||||||
user_id=get_active_user()
|
user_id=get_active_user()
|
||||||
user=get_model('base.user').browse(user_id)
|
user=get_model('base.user').browse(user_id)
|
||||||
dpt=user.department_id
|
dpt=user.department_id
|
||||||
|
branch=user.branch_id
|
||||||
if dpt:
|
if dpt:
|
||||||
branch_id=dpt.branch_id.id
|
branch_id=dpt.branch_id.id
|
||||||
comp_dom=comp_dom+[["branch_id","=",branch_id]]
|
comp_dom=comp_dom+[["branch_id","=",branch_id]]
|
||||||
|
elif branch:
|
||||||
|
branch_id=branch.id
|
||||||
|
comp_dom=comp_dom+[["branch_id","=",branch_id]]
|
||||||
elif context.get('branch_id'):
|
elif context.get('branch_id'):
|
||||||
comp_dom=comp_dom+[["branch_id","=",context['branch_id']]]
|
comp_dom=comp_dom+[["branch_id","=",context['branch_id']]]
|
||||||
|
print('com_dom ', comp_dom)
|
||||||
res=self.search(comp_dom,order="id")
|
res=self.search(comp_dom,order="id")
|
||||||
if res:
|
if res:
|
||||||
return res[0]
|
return res[0]
|
||||||
|
|
|
@ -273,6 +273,7 @@ class Shop(Model):
|
||||||
due_date=obj.date[1:10] # XXX
|
due_date=obj.date[1:10] # XXX
|
||||||
context['type']='out'
|
context['type']='out'
|
||||||
context['inv_type']='invoice'
|
context['inv_type']='invoice'
|
||||||
|
context['branch_id']=obj.branch_id.id
|
||||||
cst=get_model('clinic.setting').browse(1)
|
cst=get_model('clinic.setting').browse(1)
|
||||||
prod_acc=cst.get_product_account
|
prod_acc=cst.get_product_account
|
||||||
partner=obj.contact_id
|
partner=obj.contact_id
|
||||||
|
@ -310,8 +311,7 @@ class Shop(Model):
|
||||||
'account_id': account_id,
|
'account_id': account_id,
|
||||||
'ar_debit_id': ar_debit_id,
|
'ar_debit_id': ar_debit_id,
|
||||||
}))
|
}))
|
||||||
|
inv_id=get_model("account.invoice").create(vals,context=context)
|
||||||
inv_id=get_model("account.invoice").create(vals,context)
|
|
||||||
inv=get_model("account.invoice").browse(inv_id)
|
inv=get_model("account.invoice").browse(inv_id)
|
||||||
inv.post()
|
inv.post()
|
||||||
obj.make_pickings()
|
obj.make_pickings()
|
||||||
|
@ -390,6 +390,7 @@ class Shop(Model):
|
||||||
context={
|
context={
|
||||||
'pick_type': 'out',
|
'pick_type': 'out',
|
||||||
'journal_id': pick_vals['journal_id'],
|
'journal_id': pick_vals['journal_id'],
|
||||||
|
'branch_id': obj.branch_id.id,
|
||||||
}
|
}
|
||||||
pick_id=picking_obj.create(pick_vals,context=context)
|
pick_id=picking_obj.create(pick_vals,context=context)
|
||||||
pick=picking_obj.browse(pick_id)
|
pick=picking_obj.browse(pick_id)
|
||||||
|
@ -406,7 +407,6 @@ class Shop(Model):
|
||||||
raise Exception("No Cash Account")
|
raise Exception("No Cash Account")
|
||||||
if not income_account_id:
|
if not income_account_id:
|
||||||
raise Exception("No Income Account")
|
raise Exception("No Income Account")
|
||||||
|
|
||||||
company_id=get_active_company()
|
company_id=get_active_company()
|
||||||
vals={
|
vals={
|
||||||
"partner_id": partner.id,
|
"partner_id": partner.id,
|
||||||
|
@ -438,7 +438,11 @@ class Shop(Model):
|
||||||
'account_id': account_id,
|
'account_id': account_id,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
payment_id=get_model("account.payment").create(vals,context={"type":"in"})
|
context={
|
||||||
|
'type': 'in',
|
||||||
|
'branch_id': obj.branch_id.id,
|
||||||
|
}
|
||||||
|
payment_id=get_model("account.payment").create(vals,context=context)
|
||||||
payment=get_model('account.payment').browse(payment_id)
|
payment=get_model('account.payment').browse(payment_id)
|
||||||
payment.post()
|
payment.post()
|
||||||
obj.make_pickings()
|
obj.make_pickings()
|
||||||
|
|
Loading…
Reference in New Issue