I am trying to create new records on a Many2One field with a button, but it doesn't work.
The result is this error: TypeError: create() takes exactly 2 arguments (3 given).
I got this two class and my function:
class Line(models.Model): _name = 'inebir.line' medicament_id = fields.Many2one('inebir.medicament', string="Medicament") new_stock = fields.Integer(string="Stock") class Medicament(models.Model): _name = 'inebir.medicament' code = fields.Integer(string = "Code",required = True) name = fields.Char(string= "Nanme",required=True) description = fields.Text(string= "Description") stock = fields.Integer(string= "Stock",readonly=True) activ = fields.Boolean(string = "Registered") @api.multi def addLine(self): for m in self: line_item = { 'name':m.name, 'code':m.code, 'description':m.description, 'stock':m.stock, 'activ':m.activ } _logger.debug("HERE!") _logger.debug(line_item) result = self.env['inebir.line'].create( {'medicament_id':line_item}, {'new_stock':100} ) return result