1.so inherit here sale order and m2o field for po but it has given me error i.e except_orm:Programming Error There is no reference available for purchase.order
2.I also want to subtract purchase order subtotal price from the sale order subtotal price and show on to the sale order Total Price
class sale_inherit_course(orm.Model):
_inherit='sale.order'
_columns={
'create_course':fields.boolean('Create Course'),
'course_name':fields.many2one('openacademy.course', 'Course', ondelete="cascade"),
'responsible': fields.related('course_name', 'responsible_id', type='many2one', relation='res.users', string="co-ordinator", readonly=True),
'buy_back':fields.boolean('Buy Back'),
'purchase_order':fields.many2one('purchase.order', 'Create Back Order', ondelete="cascade"),
'responsible_me': fields.related('purchase_order', 'responsible_id', type='many2one', relation='res.users', string="User", readonly=True),
}
def create(self, cr, uid, vals, context=None):
if vals.get('create_course'):
course_obj=self.pool.get('openacademy.course')
sequence=self.pool.get('ir.sequence').get(cr, uid, 'openacademy.course.seq')
new_course=course_obj.create(cr, uid, {'name':sequence,'responsible_id':vals.get('user_id')}, context=context)
import pprint
pprint.pprint( vals )
vals['course_name']=new_course
pprint.pprint( vals )
elif vals.get('buy_back'):
purchase_obj=self.pool.get('purchase.order')
sequence=self.pool.get('ir.sequence').get(cr, uid, 'purchase.order')
new_purchase=purchase_obj.create(cr, uid, {'name':sequence,'responsible_id':vals.get('user_id')}, context=context)
vals['purchase_order']=new_purchase
return super(sale_inherit_course, self).create(cr, uid, vals, context=context)
Here Error Occur that is
except_orm: ('Programming Error', 'There is no reference available for purchase.order'