Odoo Help


2 Answers
Dan Čermák
24/08/17 08:36

Try this:

def get_price_by_pricelist(self, kwargs):
        result = {}

        all_pricelists_ids = self.env['product.pricelist'].search([('currency_id', '=', kwargs['currency_id'])])
        for pricelist_obj in self.env['product.pricelist'].browse(all_pricelists_ids):

            currency_position = pricelist_obj.currency_id.position
            currency_symbol = pricelist_obj.currency_id.symbol
            values = {}

            for product_obj in self.env['product.product'].browse(kwargs['product_ids'], context={'pricelist': pricelist_obj.id}):
                if currency_position == 'after':
                    price = str(product_obj.price) + " " + currency_symbol

                    price = currency_symbol + " " + str(product_obj.price)

                if product_obj.to_weight:
                    price = price + '/Kg'

                values[product_obj.id] = [price, product_obj.price]

            result[pricelist_obj.id] = values

        return result

You might have to fix the indentation and I have not tested this, as I do not know the context in which this function is called.

Explanation of the changes:

- in odoo > 7 the old function call signature with self, cr, uid is no longer used, instead you use a function decorator (in this case I think @api.multi might be suitable, which tells python that self gets also populated with the database context)
- database searches are no longer performed via self.pool.get ... but with self.env[].search/browse etc.

For further information, see: https://www.odoo.com/documentation/10.0/reference/orm.html

Alfie Qashwa
24/08/17 10:03
Hello Dan Čermák 

Thank you for your response. I really appreciate that

Well, i did edit the code and it return errors logs:

Odoo Server Error Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 640, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 677, in dispatch result = self._call_function(**self.params) File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 333, in _call_function return checked_call(self.db, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/odoo/service/model.py", line 101, in wrapper return f(dbname, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 326, in checked_call result = self.endpoint(*a, **kw) File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 935, in __call__ return self.method(*args, **kw) File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 506, in response_wrap response = f(*args, **kw) File "/usr/lib/python2.7/dist-packages/odoo/addons/web/controllers/main.py", line 885, in call_kw return self._call_kw(model, method, args, kwargs) File "/usr/lib/python2.7/dist-packages/odoo/addons/web/controllers/main.py", line 877, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/usr/lib/python2.7/dist-packages/odoo/api.py", line 681, in call_kw return call_kw_multi(method, model, args, kwargs) File "/usr/lib/python2.7/dist-packages/odoo/api.py", line 672, in call_kw_multi result = method(recs, *args, **kwargs) TypeError: get_price_by_pricelist() takes exactly 2 arguments (1 given)

This file is a part of pos_multi_pricelist odoo 9 by Webkul

If you can help me porting the module, please give me your email and i will send to you.


1 Comment
Dan Čermák
25/08/17 04:17

Well, the App claims support for odoo 10 though: https://www.odoo.com/apps/modules/10.0/pos_multi_pricelist/.

Anyway, my guess is, that you can fix the immediate error by changing the function signature from:

def get_price_by_pricelist(self, kwargs):


def get_price_by_pricelist(self, **kwargs):

(This just means, that all remaining function parameters will be saved in the dictionary kwargs.)

However, I think this will not fix everything, as you are querying the dictionary at this point:


But the traceback states, that only one parameter was passed (i.e. self). My guess is, that currency_id has to be obtained via different means, either from the context or from a field maybe? This depends too much on the surrounding module, so I am just guessing here.

If you need help with open source software, contact me on github or gitlab (@D4N in both cases).

Ask a Question
Keep Informed
2 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.