2015-02-04 05:13:10 +00:00
|
|
|
from netforce.model import Model, fields
|
|
|
|
|
|
|
|
class Product(Model):
|
|
|
|
_inherit="product"
|
2016-08-19 09:34:23 +00:00
|
|
|
|
2015-02-04 05:13:10 +00:00
|
|
|
_fields={
|
|
|
|
'patient_types': fields.Many2Many("clinic.patient.type","Patient Types"),
|
2015-04-22 16:43:00 +00:00
|
|
|
'departments': fields.One2Many('clinic.department.product','product_id','Departments'),
|
2015-05-08 01:09:12 +00:00
|
|
|
'report_visible': fields.Boolean("Report Visible"),
|
2015-08-19 04:00:15 +00:00
|
|
|
'account_products': fields.One2Many('clinic.setting.account.product','product_id','Account Products'),
|
2015-02-04 05:13:10 +00:00
|
|
|
}
|
|
|
|
|
2016-08-19 09:34:23 +00:00
|
|
|
#TODO
|
|
|
|
def copy_master(self,ids,context={}):
|
|
|
|
obj=self.browse(ids)[0]
|
|
|
|
master_code=obj.code.split("-")[0]
|
|
|
|
dom=[
|
|
|
|
['code','=',master_code]
|
|
|
|
]
|
|
|
|
res=self.search(dom)
|
|
|
|
if res:
|
|
|
|
raise Exception("Master product is already exist")
|
|
|
|
vals={
|
|
|
|
'code': master_code,
|
|
|
|
'name': obj.name.split("-")[0],
|
|
|
|
'description': obj.description,
|
|
|
|
'categ_id': obj.categ_id and obj.categ_id.id,
|
|
|
|
}
|
|
|
|
new_id=self.create(vals)
|
|
|
|
return {
|
|
|
|
'next': {
|
|
|
|
'name': 'product',
|
|
|
|
'mode': 'form',
|
|
|
|
'active_id': new_id,
|
|
|
|
},
|
|
|
|
'flash': "Copy master product successfull",
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-04 05:13:10 +00:00
|
|
|
Product.register()
|