This question has been flagged

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()

Avatar
Discard
Author Best Answer

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

Avatar
Discard