create shop from hd case

conv_bal
watcha.h 2015-01-29 23:38:22 +07:00
parent 1c18bb5827
commit 2c23640475
5 changed files with 66 additions and 5 deletions

View File

@ -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>

View File

@ -3,7 +3,7 @@
<field name="state"/> <field name="state"/>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="New Dialyzer" action="clinic_hd_case_dlz" states="draft,in_progress,waiting_treatment"/> <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"/> <item string="To Draft" method="to_draft" states="paid,waiting_payment,completed,cancelled"/>
</button> </button>
</head> </head>

View File

@ -12,6 +12,7 @@
<field name="ref" span="2"/> <field name="ref" span="2"/>
<field name="branch_id" span="2"/> <field name="branch_id" span="2"/>
<field name="department_id" domain='[["branch_id","=",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"/> <field name="shop_categs" invisible="1"/>
<tabs> <tabs>
<tab string="General"> <tab string="General">
@ -39,7 +40,7 @@
<field name="total"/> <field name="total"/>
</group> </group>
<foot> <foot>
<button string="Pay" type="success"/> <button string="Pay" method="pay" type="success"/>
</foot> </foot>
<related> <related>
<field name="invoices"/> <field name="invoices"/>

View File

@ -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_user,set_active_user
from netforce.access import get_active_company from netforce.access import get_active_company
class HDCase(Model): class HDCase(Model):
_name="clinic.hd.case" _name="clinic.hd.case"
_string="HD Case" _string="HD Case"
@ -1152,4 +1151,12 @@ class HDCase(Model):
data['duration']=cycle.duration data['duration']=cycle.duration
return data return data
def new_shop(self,ids,context={}):
return {
'next': {
'refer_id': ids[0],
'name': 'clinic_popup_shop',
}
}
HDCase.register() HDCase.register()

View File

@ -38,7 +38,8 @@ class Shop(Model):
"invoices": fields.One2Many("account.invoice","related_id","Invoices"), "invoices": fields.One2Many("account.invoice","related_id","Invoices"),
"payments": fields.One2Many("account.payment","related_id","Payments"), "payments": fields.One2Many("account.payment","related_id","Payments"),
'dom_str': fields.Char("Dom Str"), '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={}): def _get_branch(self,context={}):
@ -51,6 +52,25 @@ class Shop(Model):
if dpt_ids: if dpt_ids:
return dpt_ids[0] 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={ _defaults={
'number': '/', 'number': '/',
'date': lambda *a: time.strftime("%Y-%m-%d"), 'date': lambda *a: time.strftime("%Y-%m-%d"),
@ -58,7 +78,9 @@ class Shop(Model):
'branch_id': _get_branch, 'branch_id': _get_branch,
'department_id': _get_department, 'department_id': _get_department,
'state': 'draft', 'state': 'draft',
'dom_str': 'EPO', 'shop_categs': _get_shop_categs,
'related_id': _get_related,
'patient_id': _get_patient,
} }
def update_all(self,context={}): def update_all(self,context={}):
@ -91,5 +113,29 @@ class Shop(Model):
data=self.update_all(context) data=self.update_all(context)
return data 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() Shop.register()