0
votes

I added a selection type field, in purchase.py on it's class purchase.order, this field is called

sel_cert: 'sel_cert' : fields.selection([('si', 'Si'),('no','No')], 'Origen Certificado'),

So if si is selected, there is a function i made in product which fills a new field in the product_product class when purchase_order is in state 'done'

Btw there is already a function which takes product_qty on state done, draft or whatever in product

I try to "call it" in my custom function with: val = _get_product_available_func(('done')) , so it returns val if si selected in the sel_cert field in purchase.order, but idk how to do it, this is my function, and under this function there is the traceback of the error i'm getting (don't care about indentation, it's not like this in my file):

def desc_cert(self, cr, uid, ids, field_name, field_args, context=None):  
        obj = self.pool.get('purchase.order')  
        val = _get_product_available_func(('done'))  
        if obj.sel_cert == 'si':  
                return val

And the traceback:

Server Traceback (most recent call last):
File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\openerp\addons\web\session.py", line 89, in send
File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\netsvc.py", line 292, in dispatch_rpc
File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\service\web_services.py", line 626, in dispatch
File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\osv\osv.py", line 188, in execute_kw
File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\osv\osv.py", line 131, in wrapper
File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\osv\osv.py", line 197, in execute
File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\osv\osv.py", line 185, in execute_cr
File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\osv\orm.py", line 3604, in read
File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\osv\orm.py", line 3724, in _read_flat
File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\osv\fields.py", line 1133, in get
File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\openerp\addons\product\product.py", line 456, in desc_cert
NameError: global name '_get_product_available_func' is not defined

So _get_product_available_func is a function that comes before in the module product.py:

def _get_product_available_func(states, what):
    def _product_available(self, cr, uid, ids, name, arg, context=None):
        return {}.fromkeys(ids, 0.0)
    return _product_available

_product_qty_available = _get_product_available_func(('done',), ('in', 'out'))
_product_certificado_qty = _get_product_available_func(('done',), ('in', 'out'))
_product_virtual_available = _get_product_available_func(('confirmed','waiting','assigned','done'), ('in', 'out'))
_product_outgoing_qty = _get_product_available_func(('confirmed','waiting','assigned'), ('out',))
_product_incoming_qty = _get_product_available_func(('confirmed','waiting','assigned'), ('in',))

I need to return product_qty_available in productif this field sel_cert in purchase_order is 'si'

But don't know how to call it, should i use self.browse? or maybe product_available instead?

Any ideas on this?

I hope i've explained myself

Thanks in advance

2

2 Answers

1
votes

I'm going to guess that you want to write:

self._get_product_available_func
0
votes

Use self.pool.get('class name in which function is written')._get_product_available_func