[FIX] Delivery : Proper Weight calculation of stock picking
lp bug: https://launchpad.net/bugs/519220 fixed bzr revid: jvo@tinyerp.com-20100311120301-unq2j5pdo7ihcid7
This commit is contained in:
parent
41f1c7f217
commit
d9c5b69c41
|
@ -143,6 +143,30 @@
|
|||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_withweight_in_form" model="ir.ui.view">
|
||||
<field name="name">stock.picking_withweight.in.form.view</field>
|
||||
<field name="type">form</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_in_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="type" position="after">
|
||||
<field name="weight"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_withweight_internal_form" model="ir.ui.view">
|
||||
<field name="name">stock.picking_withweight.internal.form.view</field>
|
||||
<field name="type">form</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="type" position="after">
|
||||
<field name="weight"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_withcarrier_delivery_form" model="ir.ui.view">
|
||||
<field name="name">delivery.stock.picking_withcarrier.delivery.form.view</field>
|
||||
|
@ -168,6 +192,102 @@
|
|||
<field name="context">{'contact_display': 'partner'}</field>
|
||||
<field name="search_view_id" ref="stock.view_picking_out_search"/>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_withcarrier_out_move_form" model="ir.ui.view">
|
||||
<field name="name">delivery.stock.picking_withcarrier.out.move.form.view</field>
|
||||
<field name="type">form</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_out_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/notebook/page/field[@name='move_lines']/tree/field[@name='product_uom']" position="after">
|
||||
<field name="weight"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_withweight_in_move_form" model="ir.ui.view">
|
||||
<field name="name">stock.picking_withweight.in.move.form.view</field>
|
||||
<field name="type">form</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_in_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/notebook/page/field[@name='move_lines']/tree/field[@name='product_uom']" position="after">
|
||||
<field name="weight"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_withweight_internal_move_form" model="ir.ui.view">
|
||||
<field name="name">stock.picking_withweight.internal.move.form.view</field>
|
||||
<field name="type">form</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/notebook/page/field[@name='move_lines']/tree/field[@name='product_uom']" position="after">
|
||||
<field name="weight"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_withcarrier_delivery_move_form" model="ir.ui.view">
|
||||
<field name="name">delivery.stock.picking_withcarrier.delivery.move.form.view</field>
|
||||
<field name="type">form</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_delivery_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="/form/notebook/page/field[@name='move_lines']/tree/field[@name='product_uom']" position="after">
|
||||
<field name="weight"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_move_withweight_tree" model="ir.ui.view">
|
||||
<field name="name">stock.move.tree.weight</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit_id" ref="stock.view_move_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_uom" position="after">
|
||||
<field name="weight"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_move_withweight_form" model="ir.ui.view">
|
||||
<field name="name">stock.move.form.weight</field>
|
||||
<field name="type">form</field>
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit_id" ref="stock.view_move_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_uom" position="after">
|
||||
<field name="weight"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_move_reception_picking_withweight_tree" model="ir.ui.view">
|
||||
<field name="name">stock.move.reception.packing.tree.weight</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit_id" ref="stock.view_move_tree_reception_picking"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_uom" position="after">
|
||||
<field name="weight"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_move_reception_picking_withweight_form" model="ir.ui.view">
|
||||
<field name="name">stock.move.reception.packing.form.weight</field>
|
||||
<field name="type">form</field>
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit_id" ref="stock.view_move_form_reception_picking"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_uom" position="after">
|
||||
<field name="weight"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -34,15 +34,11 @@ class stock_picking(osv.osv):
|
|||
|
||||
def _cal_weight(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
data_picking = self.browse(cr, uid, ids, context)
|
||||
for picking in data_picking:
|
||||
uom_obj = self.pool.get('product.uom')
|
||||
for picking in self.browse(cr, uid, ids, context):
|
||||
total_weight = 0.00
|
||||
if picking.move_lines:
|
||||
weight = 0.00
|
||||
for move in picking.move_lines:
|
||||
if move.product_id.weight > 0.00:
|
||||
weight = (move.product_uos_qty * move.product_id.weight)
|
||||
total_weight += weight
|
||||
for move in picking.move_lines:
|
||||
total_weight += move.weight
|
||||
res[picking.id] = total_weight
|
||||
return res
|
||||
|
||||
|
@ -56,7 +52,7 @@ class stock_picking(osv.osv):
|
|||
_columns = {
|
||||
'carrier_id':fields.many2one("delivery.carrier","Carrier"),
|
||||
'volume': fields.float('Volume'),
|
||||
'weight': fields.function(_cal_weight, method=True, type='float', string='Weight',digits_compute= dp.get_precision('Stock Weight'),
|
||||
'weight': fields.function(_cal_weight, method=True, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'),
|
||||
store={
|
||||
'stock.picking': (lambda self, cr, uid, ids, c={}: ids, ['move_lines'], 20),
|
||||
'stock.move': (_get_picking_line, ['product_id','product_uos_qty'], 20),
|
||||
|
@ -127,5 +123,32 @@ class stock_picking(osv.osv):
|
|||
|
||||
stock_picking()
|
||||
|
||||
class stock_move(osv.osv):
|
||||
_inherit = 'stock.move'
|
||||
|
||||
def _cal_move_weight(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
uom_obj = self.pool.get('product.uom')
|
||||
for move in self.browse(cr, uid, ids, context):
|
||||
weight = 0.00
|
||||
if move.product_id.weight > 0.00:
|
||||
converted_qty = move.product_qty
|
||||
|
||||
if move.product_uom.id <> move.product_id.uom_id.id:
|
||||
converted_qty = uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, move.product_id.uom_id.id)
|
||||
|
||||
weight = (converted_qty * move.product_id.weight)
|
||||
res[move.id] = weight
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'weight': fields.function(_cal_move_weight, method=True, type='float', string='Weight', digits_compute= dp.get_precision('Stock Weight'),
|
||||
store={
|
||||
'stock.move': (lambda self, cr, uid, ids, c={}: ids, ['product_id', 'product_qty', 'product_uom'], 20),
|
||||
}),
|
||||
}
|
||||
|
||||
stock_move()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
Loading…
Reference in New Issue