from netforce.model import Model, fields, get_model class Hdcaseline(Model): _name="clinic.hd.case.line" _fields={ "hd_case_id": fields.Many2One("clinic.hd.case","HD Case",required=True,on_delete="cascade"), "hd_case_dis_id": fields.Many2One("clinic.hd.case.popup.discontinue","HD Case",on_delete="cascade"), "product_id": fields.Many2One("product","Product",search=True), "description": fields.Char("Description",search=True), "qty":fields.Integer("QTY"), "uom_id": fields.Many2One("uom","UOM",required=True,search=True), "price":fields.Float("Price"), "amount":fields.Float("Amount"), "type": fields.Selection([("fee","Fee"),('medicine','Medicine'),('service','Service'),("others","Others")],"Type",required=True), "product_categ_id": fields.Many2One("product.categ","Category",domain=[['expense','=',True]]), 'reimbursable': fields.Selection([['yes','Yes'],['no','No']],"Reimbursable"), 'state': fields.Selection([['draft','Draft'],['done','Done']],"State"), "account_id": fields.Many2One("account.account","Account"), } def _get_categ(self,context={}): categ_ids=get_model("product.categ").search([['code','=','EPO']]) if categ_ids: return categ_ids[0] else: return None _defaults={ 'type': 'others', 'reimbursable': 'no', 'state': 'draft', 'product_categ_id': _get_categ, } Hdcaseline.register()