from netforce.model import Model, fields, get_model from netforce.utils import get_data_path import time from netforce.access import get_active_user from netforce.access import get_active_company class Nurse(Model): _name="clinic.nurse" _string="Nurse" _audit_log=True _name_field="name" _multi_company=True _fields={ "number": fields.Char("Number",required=True,search=True), "name": fields.Char("Name",required=True,search=True), "date": fields.Date("Create Date",required=True,search=True), "birthday": fields.Date("BirthDay",required=True,search=True), "telephone": fields.Char("Telephone",required=True,search=True), "department": fields.Char("Department",required=True,search=True), "mobile": fields.Char("Mobile",required=True,search=True), "state": fields.Selection([("draft","Draft"),("active","Active"),("deactive","Deactive")],"Status",required=True), "addresses": fields.One2Many("address","related_id","Addresses"), "comments": fields.One2Many("message","related_id","Comments"), "patients": fields.Many2Many("clinic.patient","Patients"), "visits": fields.One2Many("clinic.visit","nurse_id","Visits"), "hd_cases": fields.One2Many("clinic.hd.case","nurse_id","HD cases"), "company_id": fields.Many2One("company","Company"), } def _get_number(self,context={}): while 1: num=get_model("sequence").get_number("sale_order") if not num: return None res=self.search([["number","=",num]]) if not res: return num get_model("sequence").increment("sale_order") _defaults={ "state": "draft", "date": lambda *a: time.strftime("%Y-%m-%d"), "number": _get_number, "company_id": lambda *a: get_active_company(), } _order="date desc,number desc" def void(self,ids,context={}): obj=self.browse(ids)[0] obj.write({"state":"voided"}) Nurse.register()