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

How to write/delete records to another object

By
Abdullah Sofan
on 12/6/14, 10:48 AM 517 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'),
    }
intrac_courses()

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

Anyone?

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: 12/6/14, 10:48 AM
Seen: 517 times
Last updated: 3/16/15, 8:10 AM