0
1.so繼承在此銷售訂單和M2O領域PO,但它給了我的錯誤,即except_orm:Programming Error There is no reference available for purchase.order
生成採購從銷售訂單,
2.我也想從銷售訂單小計扣除採購訂單總價格價格並顯示到銷售訂單總價
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)
這裏的錯誤發生的是
except_orm: ('Programming Error', 'There is no reference available for purchase.order'
不知道這段代碼的意思做,但我覺得可疑,你似乎以創建一個列'「purchase_order''然後總是指一列'」購買.order''。這可能是問題嗎? –
是的,我想從銷售訂單的購買訂單,並計算總價格像(sale_order_totalprice =(sale_order_subtotal_price - purchase_order_total_price)) –
是您的提示對我來說可以解決,但我如何計算購買和銷售的價值 –