Skip to Content
Menu
This question has been flagged
837 Views
class branch_good_issue_note(osv.osv):    
_inherit = ['mail.thread', 'ir.needaction_mixin']
_name = "branch.good.issue.note"

​_columns = {

'p_line':fields.one2many('branch.good.issue.note.line', 'line_id', 'Product Lines',
copy=True),
}

class branch_good_issue_note_line(osv.osv):
_name = 'branch.good.issue.note.line'
​_columns = {
​'product_viss':fields.function(_cal_viss_value, string='Viss', digits_compute=dp.get_precision('Cost Price'), type='float'),

}


def _cal_viss_value(self, cr, uid, ids, field_name, arg, context=None):
res = {}
uom_ratio = 1
if context is None:
context = {}
for order in self.browse(cr, uid, ids, context=context):
val1 = 0.0
product = self.pool.get('product.product').browse(cr, uid, order.product_id.id, context=context)
if product.uom_lines:
if len(product.uom_lines.ids) == 3:
cr.execute("select weight_ratio from product_uom where active = true and id=%s",(product.product_tmpl_id.report_uom_id.id,))
weight_ratio = cr.fetchone()[0]
if weight_ratio:
if order.issue_quantity > 0:
val1 = order.issue_quantity * (product.viss_value / weight_ratio)
else:
val1 = 0
else:
if product.product_tmpl_id.uom_id.id == order.product_uom.id:
cr.execute("select floor(round(1/factor,2)) as ratio from product_uom where active = true and id=%s", (product.product_tmpl_id.report_uom_id.id,))
bigger_qty = cr.fetchone()[0]
uom_ratio = bigger_qty
if order.issue_quantity > 0:
val1 = order.issue_quantity * (product.viss_value / uom_ratio)
else:
val1 = 0
res[order.id] = val1
return res


product_viss is not store=True

First, it is wrong, when I click "Edit" and click one line by one line. It's calcuation appear and When I click "Save" It is back to wrong value .Why???

Please Help Me !!!
Avatar
Discard
Author

Please Help!!!!!!!!!!!!11

Related Posts Replies Views Activity
0
Apr 24
1167
4
Nov 23
5090
0
Dec 22
1878
2
Dec 23
18222
0
Jun 22
1963