Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:31:42+00:00 2026-06-07T10:31:42+00:00

I have code external to OpenERP that functions as an existing product pricing system.

  • 0

I have code external to OpenERP that functions as an existing product pricing system. Each of our products have a base price that is determined in a somewhat complex way.

This external system manages and creates sales orders in OpenERP via the RPC api.

We would like to remove code from our external pricing system that calculates price information, /after/ it has already determined a base price. That is, in OpenERP terms, each product would have (say) ten different list prices.

From here, we would like to use OpenERP’s pricelist system to preform further calculations on this base price.

Currently, I have code that asks OpenERP for a product price:

...
    date_order = time.strftime(DEFAULT_SERVER_DATE_FORMAT) #Pricelists are seasonal
    price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist_id], product.id, qty, partner.id, {
        'uom': uom,
        'date': date_order,
    })[pricelist_id]

...
    price_taxes = tax_obj.compute_all(cr, uid, tax_objs, price, qty, billing_addr.id, product.id, partner.id)

This works correctly and gives me the price of a particular product.

The pricelist tree (since pricelists can be based on each other, etc) eventually calls product_product.price_get(self, cr, uid, ids, ptype='list_price', context=None) which reads the list_price via self.browse( ... )[ptype].

I think that the simplest way to modify this is a per-request override on product.list_price. By this i mean creating an rpc method that sets a variable in the context, and modifying price_get to read the context var instead of the product object.

Another alternative is to use a thread-local, but this still is a modification of the price_get function.

I was thinking about overriding the column definition and adding a getter method, but i’m not sure if it would be used from a self.browse call.

What would you recommend? Override price_get, override the column list_price, or something else?

Thanks for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:31:45+00:00Added an answer on June 7, 2026 at 10:31 am

    I solved my issue like this:

    class product_product(osv.osv):
        def _get_dyn_list_price(self, cr, uid, ids, field_name, arg, context):
            res = {}
            b = self.browse(cr, uid, ids)
            for obj in b:
                res[obj.id] = context.get('dyn_prices', {}).get(obj.id, None)
            return res
    
        _name = _inherit = 'product.product'
        _columns = {
            'dynamic_list_price': fields.function(_get_dyn_list_price, type='float', method=True, string='Dynamic List Price', store=False, digits_compute=dp.get_precision('Sale Price'), help="Dynamic base price for product after applying door styles, etc.", readonly=True),
        }
    
        def price_get(self, cr, uid, ids, ptype='list_price', context=None):
            if ptype != 'list_price':
                return super(product_product, self).price_get(cr, uid, ids, ptype, context)
            ptype = 'dynamic_list_price' #Will cause price_margin / price_extra to not be respected
            res = super(product_product, self).price_get(cr, uid, ids, ptype, context)
    
            for k, v in res.iteritems():
                if v is None:
                    if context.get('require_dyn_prices', False):
                        raise osv.except_osv('Error !', 'Dynamic prices required, but product ID not found in context.')
                    res[k] = super(product_product, self).price_get(cr, uid, [k], ptype, context)[k]
            return res
    

    Which can then be used like this:

        date_order = time.strftime(DEFAULT_SERVER_DATE_FORMAT) #Pricelists are seasonal
        price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist_id], product.id, qty, partner.id, {
            'uom': uom,
            'date': date_order,
            'dyn_prices': {product.id: unit_price},
            'require_dyn_prices': True,
        })[pricelist_id]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that launches an external application and automatically fills in a password
I have some code that launches an external program, although is it possible to
I have code called from a servlet that calls out to an external service.
I have some code that pulls HTML from an external source: $doc = new
I have this jQuery code that retrieves external content using ajax, without refereshing the
I have a code base that makes extensive use of files to represent a
I have a code base that can be customized for different customers. This is
I have a code which communicates with external hardware in the system. As per
I have the following code in my external JS file: var myDiv = $(.myDiv);
I have c#.net code which calls a method from another external/referenced .net assembly. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.