[IMP] Improve the copying of products and make sure the orderpoints apply their copy method
bzr revid: jco@openerp.com-20140414084821-1yi87wk6cfrr69qg
This commit is contained in:
parent
f8aef0b59e
commit
4768c24340
|
@ -300,7 +300,7 @@ class prices_history(osv.osv):
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'company_id': fields.many2one('res.company', required=True),
|
'company_id': fields.many2one('res.company', required=True),
|
||||||
'product_template_id': fields.many2one('product.template', 'Product Template', required=True),
|
'product_template_id': fields.many2one('product.template', 'Product Template', required=True, ondelete='cascade'),
|
||||||
'datetime': fields.datetime('Historization Time'),
|
'datetime': fields.datetime('Historization Time'),
|
||||||
'cost': fields.float('Historized Cost'),
|
'cost': fields.float('Historized Cost'),
|
||||||
'reason': fields.char('Reason'),
|
'reason': fields.char('Reason'),
|
||||||
|
|
|
@ -291,6 +291,22 @@ class product_product(osv.osv):
|
||||||
result['domain'] = "[('id','in',[" + ','.join(map(str, route_ids)) + "])]"
|
result['domain'] = "[('id','in',[" + ','.join(map(str, route_ids)) + "])]"
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def copy(self, cr, uid, id, default=None, context=None):
|
||||||
|
context = context or {}
|
||||||
|
default = dict(default or {})
|
||||||
|
|
||||||
|
product = self.browse(cr, uid, id, context=context)
|
||||||
|
op_obj = self.pool.get('stock.warehouse.orderpoint')
|
||||||
|
op_ids = []
|
||||||
|
for orderpoint in product.orderpoint_ids:
|
||||||
|
op_val = op_obj.copy(cr, uid, orderpoint.id, context=context)
|
||||||
|
op_ids.append(op_val)
|
||||||
|
default['orderpoint_ids'] = [(6, 0, op_ids)]
|
||||||
|
res = super(product_product, self).copy(cr, uid, id, default=default, context=context)
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
class product_template(osv.osv):
|
class product_template(osv.osv):
|
||||||
_name = 'product.template'
|
_name = 'product.template'
|
||||||
_inherit = 'product.template'
|
_inherit = 'product.template'
|
||||||
|
|
Loading…
Reference in New Issue