Note that there are some explanatory texts on larger screens.

plurals
  1. POIn openerp, how can I override the base list price of a product?
    primarykey
    data
    text
    <p>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.</p> <p>This external system manages and creates sales orders in OpenERP via the RPC api.</p> <p>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.</p> <p>From here, we would like to use OpenERP's pricelist system to preform further calculations on this base price.</p> <p>Currently, I have code that asks OpenERP for a product price:</p> <pre><code>... 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) </code></pre> <p>This works correctly and gives me the price of a particular product.</p> <p>The pricelist tree (since pricelists can be based on each other, etc) eventually calls <code>product_product.price_get(self, cr, uid, ids, ptype='list_price', context=None)</code> which reads the list_price via <code>self.browse( ... )[ptype]</code>. </p> <p>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.</p> <p>Another alternative is to use a thread-local, but this still is a modification of the price_get function.</p> <p>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.</p> <p>What would you recommend? Override <code>price_get</code>, override the column <code>list_price</code>, or something else?</p> <p>Thanks for the help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload