[IMP] Add store on package company_id and add owner, add parent_left/right store
bzr revid: jco@openerp.com-20130906095726-ozz6lohbujidgm23
This commit is contained in:
parent
f0f8fcb46e
commit
4952b96ff7
|
@ -173,7 +173,7 @@ class procurement_order(osv.osv):
|
||||||
'product_uom': product.uom_id.id,
|
'product_uom': product.uom_id.id,
|
||||||
'location_id': location_id,
|
'location_id': location_id,
|
||||||
'company_id': warehouse.company_id.id,
|
'company_id': warehouse.company_id.id,
|
||||||
'procure_method': 'make_to_order',}
|
}
|
||||||
|
|
||||||
def create_automatic_op(self, cr, uid, context=None):
|
def create_automatic_op(self, cr, uid, context=None):
|
||||||
"""
|
"""
|
||||||
|
@ -204,7 +204,7 @@ class procurement_order(osv.osv):
|
||||||
|
|
||||||
product = product_obj.browse(cr, uid, [product_read['id']], context=context)[0]
|
product = product_obj.browse(cr, uid, [product_read['id']], context=context)[0]
|
||||||
if product.supply_method == 'buy':
|
if product.supply_method == 'buy':
|
||||||
location_id = warehouse.lot_input_id.id
|
location_id = warehouse.lot_stock_id.id
|
||||||
elif product.supply_method == 'produce':
|
elif product.supply_method == 'produce':
|
||||||
location_id = warehouse.lot_stock_id.id
|
location_id = warehouse.lot_stock_id.id
|
||||||
else:
|
else:
|
||||||
|
@ -212,8 +212,8 @@ class procurement_order(osv.osv):
|
||||||
proc_id = proc_obj.create(cr, uid,
|
proc_id = proc_obj.create(cr, uid,
|
||||||
self._prepare_automatic_op_procurement(cr, uid, product, warehouse, location_id, context=context),
|
self._prepare_automatic_op_procurement(cr, uid, product, warehouse, location_id, context=context),
|
||||||
context=context)
|
context=context)
|
||||||
self.signal_button_confirm(cr, uid, [proc_id])
|
self.assign(cr, uid, [proc_id])
|
||||||
self.signal_button_check(cr, uid, [proc_id])
|
self.run(cr, uid, [proc_id])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_orderpoint_date_planned(self, cr, uid, orderpoint, start_date, context=None):
|
def _get_orderpoint_date_planned(self, cr, uid, orderpoint, start_date, context=None):
|
||||||
|
@ -229,7 +229,6 @@ class procurement_order(osv.osv):
|
||||||
'company_id': orderpoint.company_id.id,
|
'company_id': orderpoint.company_id.id,
|
||||||
'product_uom': orderpoint.product_uom.id,
|
'product_uom': orderpoint.product_uom.id,
|
||||||
'location_id': orderpoint.location_id.id,
|
'location_id': orderpoint.location_id.id,
|
||||||
'procure_method': 'make_to_order',
|
|
||||||
'origin': orderpoint.name}
|
'origin': orderpoint.name}
|
||||||
|
|
||||||
def _product_virtual_get(self, cr, uid, order_point):
|
def _product_virtual_get(self, cr, uid, order_point):
|
||||||
|
|
|
@ -1950,7 +1950,10 @@ class stock_package(osv.osv):
|
||||||
"""
|
"""
|
||||||
_name = "stock.quant.package"
|
_name = "stock.quant.package"
|
||||||
_description = "Physical Packages"
|
_description = "Physical Packages"
|
||||||
_order = 'name'
|
_parent_name = "parent_id"
|
||||||
|
_parent_store = True
|
||||||
|
_parent_order = 'name'
|
||||||
|
_order = 'parent_left'
|
||||||
|
|
||||||
def name_get(self, cr, uid, ids, context=None):
|
def name_get(self, cr, uid, ids, context=None):
|
||||||
res = self._complete_name(cr, uid, ids, 'complete_name', None, context=context)
|
res = self._complete_name(cr, uid, ids, 'complete_name', None, context=context)
|
||||||
|
@ -1985,16 +1988,20 @@ class stock_package(osv.osv):
|
||||||
res.add(pack.parent_id.id)
|
res.add(pack.parent_id.id)
|
||||||
return list(res)
|
return list(res)
|
||||||
|
|
||||||
|
# TODO: Problem when package is empty!
|
||||||
|
#
|
||||||
def _get_package_info(self, cr, uid, ids, name, args, context=None):
|
def _get_package_info(self, cr, uid, ids, name, args, context=None):
|
||||||
default_company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
|
default_company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
|
||||||
res = {}.fromkeys(ids, {'location_id': False, 'company_id': default_company_id})
|
res = {}.fromkeys(ids, {'location_id': False, 'company_id': default_company_id})
|
||||||
for pack in self.browse(cr, uid, ids, context=context):
|
for pack in self.browse(cr, uid, ids, context=context):
|
||||||
if pack.quant_ids:
|
if pack.quant_ids:
|
||||||
res[pack.id]['location_id'] = pack.quant_ids[0].location_id.id
|
res[pack.id]['location_id'] = pack.quant_ids[0].location_id.id
|
||||||
|
res[pack.id]['owner_id'] = pack.quant_ids[0].owner_id and pack.quant_ids[0].owner_id.id or False
|
||||||
res[pack.id]['company_id'] = pack.quant_ids[0].company_id.id
|
res[pack.id]['company_id'] = pack.quant_ids[0].company_id.id
|
||||||
elif pack.children_ids:
|
elif pack.children_ids:
|
||||||
res[pack.id]['location_id'] = pack.children_ids[0].location_id.id
|
res[pack.id]['location_id'] = pack.children_ids[0].location_id and pack.children_ids[0].location_id.id or False
|
||||||
res[pack.id]['company_id'] = pack.children_ids[0].company_id.id
|
res[pack.id]['owner_id'] = pack.children_ids[0].owner_id and pack.children_ids[0].owner_id.id or False
|
||||||
|
res[pack.id]['company_id'] = pack.children_ids[0].company_id and pack.children_ids[0].company_id.id or False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
|
@ -2006,12 +2013,21 @@ class stock_package(osv.osv):
|
||||||
'location_id': fields.function(_get_package_info, type='many2one', relation='stock.location', string='Location', multi="package",
|
'location_id': fields.function(_get_package_info, type='many2one', relation='stock.location', string='Location', multi="package",
|
||||||
store={
|
store={
|
||||||
'stock.quant': (_get_packages, ['location_id'], 10),
|
'stock.quant': (_get_packages, ['location_id'], 10),
|
||||||
'stock.quant.package': (_get_packages_to_relocate, ['children_ids', 'quant_ids', 'parent_id'], 10),
|
'stock.quant.package': (_get_packages_to_relocate, ['quant_ids', 'children_ids', 'parent_id'], 10),
|
||||||
}, readonly=True),
|
}, readonly=True),
|
||||||
'quant_ids': fields.one2many('stock.quant', 'package_id', 'Bulk Content'),
|
'quant_ids': fields.one2many('stock.quant', 'package_id', 'Bulk Content'),
|
||||||
'parent_id': fields.many2one('stock.quant.package', 'Parent Package', help="The package containing this item"),
|
'parent_id': fields.many2one('stock.quant.package', 'Parent Package', help="The package containing this item"),
|
||||||
'children_ids': fields.one2many('stock.quant.package', 'parent_id', 'Contained Packages'),
|
'children_ids': fields.one2many('stock.quant.package', 'parent_id', 'Contained Packages'),
|
||||||
'company_id': fields.function(_get_package_info, type="many2one", relation='res.company', string='Company', multi="package"),
|
'company_id': fields.function(_get_package_info, type="many2one", relation='res.company', string='Company', multi="package",
|
||||||
|
store={
|
||||||
|
'stock.quant': (_get_packages, ['company_id'], 10),
|
||||||
|
'stock.quant.package': (_get_packages_to_relocate, ['quant_ids', 'children_ids', 'parent_id'], 10),
|
||||||
|
}, readonly=True),
|
||||||
|
'owner_id': fields.function(_get_package_info, type='many2one', relation='res.partner', string='Owner', multi="package",
|
||||||
|
store={
|
||||||
|
'stock.quant': (_get_packages, ['owner_id'], 10),
|
||||||
|
'stock.quant.package': (_get_packages_to_relocate, ['quant_ids', 'children_ids', 'parent_id'], 10),
|
||||||
|
}, readonly=True),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'name': lambda self, cr, uid, context: self.pool.get('ir.sequence').get(cr, uid, 'stock.quant.package') or _('Unknown Pack')
|
'name': lambda self, cr, uid, context: self.pool.get('ir.sequence').get(cr, uid, 'stock.quant.package') or _('Unknown Pack')
|
||||||
|
|
|
@ -614,7 +614,7 @@
|
||||||
<field name="lot_id" groups="stock.group_production_lot"/>
|
<field name="lot_id" groups="stock.group_production_lot"/>
|
||||||
<field name="package_id" groups="stock.group_tracking_lot"/>
|
<field name="package_id" groups="stock.group_tracking_lot"/>
|
||||||
<field name="owner_id" groups="stock.group_tracking_owner"/>
|
<field name="owner_id" groups="stock.group_tracking_owner"/>
|
||||||
<field name="product_qty"/>
|
<field name="product_qty" attrs="{'required': [('product_id', '!=', False)]}"/>
|
||||||
<field name="result_package_id" groups="stock.group_tracking_lot"/>
|
<field name="result_package_id" groups="stock.group_tracking_lot"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
@ -1725,6 +1725,7 @@
|
||||||
<group>
|
<group>
|
||||||
<field name="packaging_id"/>
|
<field name="packaging_id"/>
|
||||||
<field name='company_id' groups="base.group_multi_company"/>
|
<field name='company_id' groups="base.group_multi_company"/>
|
||||||
|
<field name='owner_id' groups="stock.group_tracking_owner"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="location_id"/>
|
<field name="location_id"/>
|
||||||
|
|
Loading…
Reference in New Issue