Odoo Help

0

One2Many or Many2Many / Correctness vs Functioning

By
C S
on 11/16/16, 5:45 AM 485 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. 

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.

Register

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)

Stats

Asked: 11/16/16, 5:45 AM
Seen: 485 times
Last updated: 11/16/16, 9:39 AM