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.
Hello, i've one doubt:
I created a field called ' niu ' to increase its value for each product type stockable.
niu = fields.Char(string="NIU", compute="_niu_validation", defalut=" ", readonly=True)
With the attribute compute = "_ niu_validation " I call the method of the same name . In this , I want to validate that the product type is stockable type .
if 'product_id.product_tmpl_id.type' == 'product':
niu = lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'sale.order.line')
<?xml version="1.0" encoding="utf-8"?>
On the other hand I created the render sequence for ' niu ' field in sale.order.line model.
<!-- Sequence for sale.order.line -->
<record id="seq_sale_order_line" model="ir.sequence">
<field name="name">NIU Sequence</field>
And in the view , I want for each product type stockable, the field 'niu' increase its value.
Please I need help because I 've been a long time on this and I can't do it on my own. I hope your help , advice , recommendations. Thank you very much to all.
Try Below field definition and code for create sequence automatically.
Field Definition :-
niu = fields.Char('NIU', readonly=True, select=True, copy=False, default='New')
Create Method :-
def create(self, vals):
if vals.get('name', 'New') == 'New':
vals['name'] = self.env['ir.sequence'].next_by_code('model.name') or 'New'
result = super(ModelName, self).create(vals)
Hope it works for you.
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: 2/26/16, 6:29 AM|
|Seen: 1897 times|
|Last updated: 3/2/16, 8:24 AM|