Odoo Help


How to write/delete records to another object

Abdullah Sofan
on 12/6/14, 10:48 AM 729 views

I have this model which is able to create a course and a fee and also creates a product with the same name as the course name as well as a list price of the same coursefee value.

I need to know the code that changes the values of the product name and list price whenever I edit the values of course name and course fees in my module. Also, I need the code that deletes the product whoch was created when the course was created.

I have been struggling with this for a couple of days now.

Your help is appreciated. 

class intrac_courses(osv.osv):

    def create(self, cr, uid, vals, context=None):
        if not vals:
            vals = {}
        if context is None:
           context = {}
        product_name = vals.get('name', '1')
        product_fee = vals.get('course_fee', '0.0')

        product_obj = self.pool.get('product.template')
        product_type = 'service'
        product_obj.create(cr, uid, {'name' : product_name, 'type': product_type, 'list_price': product_fee, 'description': product_desc }, context=context)
        return super(intrac_courses, self).create(cr, uid, vals, context=context)

    _name = 'intrac.courses'
    _columns = {
        'name': fields.char('Course Name', size=100, required=True),
        'course_fee': fields.char('Fees Per Trainee'),

Abdullah Sofan
On 12/6/14, 6:28 PM


About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 12/6/14, 10:48 AM
Seen: 729 times
Last updated: 3/16/15, 8:10 AM