I am inheriting the create function for the mrp.production model and I am trying to create a mrp.partsorder record that is related to the first. My function is creating records in both tables in the database, but the "sourceorder_id" field is empty. I've tried several variations, but this is my current code:
class mrp_production(osv.osv): """ Production Orders / Manufacturing Orders """ _inherit = 'mrp.production' _columns = { 'partsorder_ids': fields.one2many('mrp.partsorder', 'sourceorder_id', string="Parts Orders"), } def create(self, cr, uid, vals, context=None): res = super(mrp_production, self).create(cr, uid, vals, context) partsorder_ids = self.pool.get('mrp.partsorder').create(cr,uid, vals, context=context) return res
class mrp_partsorder(osv.Model): _name = 'mrp.partsorder' _columns = { 'completedby_id': fields.many2one('res.users', string="Completed By"), 'sourceorder_id': fields.many2one('mrp.production', string="Source Order") }
I've also tried to assign a tuple like so:
partsorder_id = self.pool.get('mrp.partsorder').write(cr, uid, [partsorder], {'partsorder': [(0,0, {'completedby_id'=user.id'})]})
I've even tried just assigning a tuple to the one2many variable so that it will be called and assigned using (0,0). Like so
def create(self, cr, uid, vals, context=None): res = super(mrp_production, self).create(cr, uid, vals, context) partsorder_ids = [] partsorder_ids.append((0,0, {'scheduleDate':'meowmix9'})) return res
My goal is to simply have a record created in the marp.partsorder model that is related to the mrp.production model everytime an mrp.production record is created. The create function works fine, but no data is stored in the database for the relationship. In other words the sourceorder_id field is empty on the partsorder table in the database.