from netforce.model import Model, fields class DepartmentProduct(Model): _name="clinic.department.product" _string="Department Product" _key=['product_id','department_id'] _fields={ "product_id": fields.Many2One("product","Product", required=True), "department_id": fields.Many2One("clinic.department","Working Department", required=True), "stock_journal_id": fields.Many2One("stock.journal","Stock Journal",required=True), } def get_location(self,department_id,product_id,context={}): for obj in self.search_browse([]): if obj.department_id.id==department_id and obj.product_id.id==product_id: return { 'wh_loc_id': obj.stock_journal_id.location_from_id.id, 'cust_loc_id': obj.stock_journal_id.location_to_id.id, 'journal_id': obj.stock_journal_id.id, } DepartmentProduct.register()