create shop from hd case
parent
1c18bb5827
commit
2c23640475
|
@ -0,0 +1,7 @@
|
|||
<action>
|
||||
<field name="string">Shop RD</field>
|
||||
<field name="view_cls">form_popup</field>
|
||||
<field name="model">clinic.shop</field>
|
||||
<field name="target">_popup</field>
|
||||
<field name="width">1000</field>
|
||||
</action>
|
|
@ -3,7 +3,7 @@
|
|||
<field name="state"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<item string="New Dialyzer" action="clinic_hd_case_dlz" states="draft,in_progress,waiting_treatment"/>
|
||||
<item string="Shop RD" action="clinic_todo" states="draft,in_progress,waiting_treatment"/>
|
||||
<item string="Shop RD" method="new_shop" states="draft,in_progress,waiting_treatment"/>
|
||||
<item string="To Draft" method="to_draft" states="paid,waiting_payment,completed,cancelled"/>
|
||||
</button>
|
||||
</head>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<field name="ref" span="2"/>
|
||||
<field name="branch_id" span="2"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||
<field name="related_id" span="2"/>
|
||||
<field name="shop_categs" invisible="1"/>
|
||||
<tabs>
|
||||
<tab string="General">
|
||||
|
@ -39,7 +40,7 @@
|
|||
<field name="total"/>
|
||||
</group>
|
||||
<foot>
|
||||
<button string="Pay" type="success"/>
|
||||
<button string="Pay" method="pay" type="success"/>
|
||||
</foot>
|
||||
<related>
|
||||
<field name="invoices"/>
|
||||
|
|
|
@ -6,7 +6,6 @@ from netforce.utils import get_data_path, get_file_path
|
|||
from netforce.access import get_active_user,set_active_user
|
||||
from netforce.access import get_active_company
|
||||
|
||||
|
||||
class HDCase(Model):
|
||||
_name="clinic.hd.case"
|
||||
_string="HD Case"
|
||||
|
@ -1151,5 +1150,13 @@ class HDCase(Model):
|
|||
data['time_stop']=time_stop
|
||||
data['duration']=cycle.duration
|
||||
return data
|
||||
|
||||
def new_shop(self,ids,context={}):
|
||||
return {
|
||||
'next': {
|
||||
'refer_id': ids[0],
|
||||
'name': 'clinic_popup_shop',
|
||||
}
|
||||
}
|
||||
|
||||
HDCase.register()
|
||||
|
|
|
@ -38,7 +38,8 @@ class Shop(Model):
|
|||
"invoices": fields.One2Many("account.invoice","related_id","Invoices"),
|
||||
"payments": fields.One2Many("account.payment","related_id","Payments"),
|
||||
'dom_str': fields.Char("Dom Str"),
|
||||
'shop_categs': fields.Many2Many("product.categ","Categs",function="_get_all",function_multi=True),
|
||||
'shop_categs': fields.Many2Many("product.categ","Categs",function="_get_all",function_multi=True,store=True),
|
||||
"related_id": fields.Reference([["sale.order","Sales Order"],["purchase.order","Purchase Order"],["project","Project"],["job","Service Order"],["service.contract","Service Contract"]],"Related To"),
|
||||
}
|
||||
|
||||
def _get_branch(self,context={}):
|
||||
|
@ -50,6 +51,25 @@ class Shop(Model):
|
|||
dpt_ids=get_model('clinic.department').search([])
|
||||
if dpt_ids:
|
||||
return dpt_ids[0]
|
||||
|
||||
def _get_shop_categs(self,context={}):
|
||||
st=get_model("clinic.setting").browse(1)
|
||||
shop_categs=[x.id for x in st.shop_categs]
|
||||
return shop_categs
|
||||
|
||||
def _get_related(self,context={}):
|
||||
related_id=None
|
||||
if context.get('refer_id'):
|
||||
related_id="clinic.hd.case,%s"%context.get("refer_id")
|
||||
return related_id
|
||||
|
||||
def _get_patient(self,context={}):
|
||||
patient_id=None
|
||||
if context.get('refer_id'):
|
||||
refer_id=context.get("refer_id")
|
||||
hd_case=get_model("clinic.hd.case").browse(refer_id)
|
||||
patient_id=hd_case.patient_id.id
|
||||
return patient_id
|
||||
|
||||
_defaults={
|
||||
'number': '/',
|
||||
|
@ -58,7 +78,9 @@ class Shop(Model):
|
|||
'branch_id': _get_branch,
|
||||
'department_id': _get_department,
|
||||
'state': 'draft',
|
||||
'dom_str': 'EPO',
|
||||
'shop_categs': _get_shop_categs,
|
||||
'related_id': _get_related,
|
||||
'patient_id': _get_patient,
|
||||
}
|
||||
|
||||
def update_all(self,context={}):
|
||||
|
@ -91,5 +113,29 @@ class Shop(Model):
|
|||
data=self.update_all(context)
|
||||
return data
|
||||
|
||||
def create(self,vals,**kw):
|
||||
id=super().create(vals,**kw)
|
||||
self.function_store([id])
|
||||
return id
|
||||
|
||||
def write(self,ids,vals,**kw):
|
||||
super().write(ids,vals,**kw)
|
||||
self.function_store(ids)
|
||||
|
||||
def pay(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
active_id=obj.id
|
||||
action="clinic_shop"
|
||||
if obj.related_id:
|
||||
active_id=obj.related_id.id
|
||||
action="clinic_hd_case"
|
||||
return {
|
||||
'next': {
|
||||
'name': action,
|
||||
'mode': 'form',
|
||||
'active_id': active_id,
|
||||
},
|
||||
'flash': 'Pay Successfully',
|
||||
}
|
||||
|
||||
Shop.register()
|
||||
|
|
Loading…
Reference in New Issue