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.
Im trying to override odoo 9 sale.order create method, so that only products belonging to the same category can be sold:
from openerp import api
from openerp.osv import fields, osv
from openerp.tools.translate import _
from openerp.exceptions import UserError, ValidationError
_inherit = "sale.order"
def create(self, vals):
if vals.get('name', 'New') == 'New':
for l in order_lines_vals:
for value in l:
if isinstance(value, dict):
for j in self.env['product.product'].browse(product_ids):
if len(product_categ_ids) > 1:
raise ValidationError(_("Is not possible to add products belonging to more than one category!"))
result = super(SaleOrder, self).create(vals)
Everything works fine except the error, record is not created but no popup window error is displayed,,,,,does anyone know how to handle correctly with exceptions in odoo 9?
Thanks in advance
Hello Diego Calzadilla,
First of all you are inherited sale order in v7 style.
for v9 you have to inherit as following:
_name = 'sale.order'
Here your code seems fine except that super call, in super call you have to mention class name.
so as per your code, super call must be like
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: 3/21/16, 11:45 AM|
|Seen: 963 times|
|Last updated: 8/16/16, 10:00 AM|