This question has been flagged

I have an object that, when it completes it's workflow, needs to update the state for a different class, specifically manufacturing orders. I have tried everything I can think of to try to update that field. Code is thus:

class mrp_partsorder(osv.Model):
...

_columns = {
'sourceorder_id': fields.many2one('mrp.production', string='Manufacturing Order'
'primarystate': fields.selection ( [..states...], related='sourceorder_id.state'
}

def partsorder_complete(self, cr, uid, ids, context=None):
prod_obj = self.pool.get('mrp.production')
prod_ids = [self.sourceorder_id]
prods = prod_obj.search(cr, uid, prod_ids, context=context)
proc_obj.action_fitting(cr, uid, prods, context=context)
res = self.write(cr, uid, ids, {'state': 'complete'}, context=context)

class mrp_production(osv.osv)
def action_fitting(self, cr, uid, ids, context=None):
res = self.write(cr, uid, ids, {'state': 'fitting'}, context=context) return res
 


At the moment I'm getting the following error:

ValueError: "'mrp.partsorder' object has no attribute '_ids'" while evaluating
u'partsorder_complete()

This is not the only error I've seen, as I've tried quite a few different ideas of solving this problem. Basically, i just want to update the value in the related field (primarystate), but if I write to that field it updates the mrp.partsorder table but not the mrp.production table. So, I figured I needed to use self.pool.get to get the singleton instance of mrp.production and then use the the write method for mrp.production or use the action_fitting() method for mrp.production. 

What is the best way to solve this problem?

Edit: After further consideration I realized that I need to use the function on mrp.production to change the state, rather than just writing to it. I want to do this because of all the functionality built into the manufacturing order. All I need now is to figure out how to call the function from my mrp.partsorder.partsorder_complete() function. 

Avatar
Discard
Author

So I have now tried doing something like: mrp_order = self.pool.get('mrp.production') order_ids = self.sourceorder_id for order in mrp_order.browse(cr, uid, order_ids): order.action_fitting() I think that fixes some syntax issues I have, but I'm still getting the same error. The worst part is it is saying mrp.partsorder has no attribute _ids, which is odd since the function I'm calling is from the mrp.production object.

Author

As a follow up, mrp.partsorder shouldn't be called until the end of the partsorder_complete() function. So, the should be no problem running the action_fitting() function, unless the error is happening when I try to pass the sourceorder_ids (the m2o relationship between mrp.partsorders and mrp.production) to prod_ids.