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.

0

One2Many or Many2Many / Correctness vs Functioning

By
C S
on 11/16/16, 5:45 AM 119 views

I want to put many "lines" on one confirmation document. I would figure a one2many would work, but I couldn't program it to behave as such. I did, however, get a many2many to work albeit not correctly written. I want to be able to fill out the lines on the same form as the parent, like a one2many does. I don't want to "add item" then "create" then fill out the form, like my many2many implementation has done it. Plus, i'd like to learn the correct way. Could anyone help me implement these lines as either a one2many or many2many where you can fill them out on the parent form?



class OrderConfirmation(models.Model):

    _name = 'order.confirmation' #_inherit = 'res.partner'

    _columns = {

    'name': fields.char(string='Auftragnummer', required=True),

    'customer_id': fields.many2one('res.partner', string='Customer', select=True, required=True),  

    'order_date': fields.date(string='Date', default=date.today()), 'gender': fields.selection([('male','Herr'),('female','Frau')],'Title',     required=True),

    'order_confirmation_line': fields.many2many('order.confirmation.line', string='Items'),

}


class OrderConfirmationLine(models.Model):

    _name = 'order.confirmation.line'

    _columns = {

    'device_quantity': fields.char(string='Menge', default='1'),

    'serialnumber': fields.char(string='Seriennummer / IMEI'),

    'item_name': fields.char(string='Item Name', default='Macbook'),

    'manufacturer': fields.char(string='Hersteller', default='Apple'), 'model_number': fields.char(string='Model'),

}

OrderConfirmation()

0
C S
On 11/16/16, 7:31 AM

I figured out I could simply add widget="one2many" to my form and my many2many now behaves as such. 

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: 11/16/16, 5:45 AM
Seen: 119 times
Last updated: 11/16/16, 9:39 AM