Odoo Help
Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM
|
e-Commerce
|
Accounting
|
Inventory
|
PoS
|
Project management
|
MRP
|
etc.
sale quotation: check if unit_price lower than purchase price
Hi
I'm currently am worken on a way to check if the unit_price on the sale order line is lower than the standard_price on the product of that line. if the unit price is lower than the standard_price than the user should get an error and can't create a new line. If the unit_price is higher equal or null nothing should happen. currently i get an error
TypeError: result is null
Here is my code .py
def check_margin(self, cr, uid, ids, product_id, context=None):
if product_id:
purchase_price = self.pool.get('product.product').browse(cr, uid, product_id).standard_price
unit_price= self.browse(cr, uid, product_id).price_unit
if unit_price is None:
pass
elif unit_price < purchase_price:
raise osv.except_osv(('fout'),('Verkoopprijs moet lager zijn dan aankoopprijs'))
elif unit_price > purchase_price:
pass
.xml
<record model="ir.ui.view" id="sale_margin_sale_order_line">
<field name="name">sale.order.line.margin.view.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/form//field[@name='price_unit']" position="after">
<field name="purchase_price" groups="base.group_user"/>
</xpath>
<xpath expr="//field[@name='order_line']/tree//field[@name='price_unit']" position="replace">
<field name="price_unit" on_change="check_margin('product_id')"/>
</xpath>
</field>
</record>
what am i doing row i'm just new in creating functions in openerp
with regards
Kris Coenen
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.
RegisterOdoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.
Test it nowQuestion tools
Stats
Asked: 10/15/13, 12:25 PM |
Seen: 1078 times |
Last updated: 3/16/15, 8:10 AM |
Hi Kris Conenen . did you solve this? Me also facing this please help..