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.
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
<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
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 10/15/13, 12:30 PM|
|Seen: 1090 times|
|Last updated: 3/16/15, 8:10 AM|