(Python代码)内部函数调用OpenERP v7中的另一个函数?

时间:2013-11-06 07:44:19

标签: python function openerp

我有一个函数来比较两个不同的字段:

功能A:

    def on_change_expected_qty(self, cr, uid, ids, finish_product_quantity):
            res = {}
            for rec in self.browse(cr, uid, ids):
                expected_qty = 0.0
                for line_rec in rec.bom_lines:
                    expected_qty += line_rec.product_qty or 0.0
                if finish_product_quantity != expected_qty:
                    if finish_product_quantity > expected_qty:
                        tot_produce = finish_product_quantity - expected_qty
                        res['remarks'] = 'Finish product is produce EXTRA ' + str(tot_produce) +  str(rec.product_uom.name)
                    else:
                        tot_produce = expected_qty - finish_product_quantity
                        res['remarks'] = 'Finish product is produce LESS ' + str(tot_produce) +  str(rec.product_uom.name)

            return {'value':res}

然后我有另一个计算单位成本的函数:

功能B:

 def get_unit_cost_calculation(self, cr, uid, ids, name, args, context=None):
        res = {}
        for rec in self.browse(cr, uid, ids, context=context):
            total_unit_cost = 0.0
            if rec.total_production_cost > 0 and rec.finish_product_quantity > 0:
                total_unit_cost = rec.total_production_cost / rec.finish_product_quantity
            res.update({rec.id : total_unit_cost})
        return res

在我的FUNCTION B完成后如何调用我的FUNCTION B中的FUNCTION A来计算单位成本?

请提供帮助和建议。

谢谢。

1 个答案:

答案 0 :(得分:0)

您可以简单地将其称为

self.on_change_expected_qty(cr, uid, [rec.id], rec.finish_product_quantity)