Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Perform action on click Boolean Field

By
Atul Kumar jain
on 1/13/14, 8:46 AM 1,741 views

I want to Generate Purchase Order From the sale order, so i inherit here sale order and many2one field for purchase order error but it has given me error that is except_orm: ('Programming Error', 'There is no reference available for purchase.order'

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'

2

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 1/13/14, 8:55 AM

Have you checked the Sale Module Depends Purchase module added in __openerp__.py File ?? If not add the depends

'depends':['purchase']

i want to create function that can compute purchase order value and sale order value so how i can do that

Atul Kumar jain
on 1/14/14, 3:01 AM
2

Atul Kumar jain

--Atul Kumar jain--
914
| 5 3 7
Indore, India
--Atul Kumar jain--

.

Atul Kumar jain
On 1/13/14, 8:47 AM

I am getting stuck to solve this problem

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/13/14, 8:46 AM
Seen: 1741 times
Last updated: 3/16/15, 8:10 AM