Odoo Help


2 Answers

Niyas Raphy

--Niyas Raphy--
| 7 6 11
Calicut, India
--Niyas Raphy--

Odoo Techno Functionalist

Feel free to connect :  niyasraphyk@gmail.com

LinkedIn: https://www.linkedin.com/in/niyasraphy/

Happy to help :)

Niyas Raphy
7/17/18, 1:58 PM


If you are looking to create a sequence for the model maintenance request , like in the sales, like SO001,SO002 etc,

In the XML file create a sequence like this,

<record id="seq_material_request" model="ir.sequence">
<field name="name">Material Request</field>
<field name="code">material.request</field>
<field name="prefix">MR</field>
<field name="padding">3</field>
<field name="company_id" eval="False"/>


You have to define a field in python in this model and you have to write the value to it, for that

name = fields.Char(string='Request  No', required=True, copy=False, readonly=True,
index=True, default=lambda self: _('New'))

def create(self, vals):
"""Overriding the create method and assigning the the sequence for the record"""
if vals.get('name', _('New')) == _('New'):
vals['name'] = self.env['ir.sequence'].next_by_code('material.request') or _('New')
res = super(ClassName, self).create(vals)
return res


Luis Jacobo
7/19/18, 3:48 PM

Perfect Niyas,

With that i added the sequence.

in a view, how can call the current id applied to a maintenance request. Im using the print maintenance request module.


Niyas Raphy
7/19/18, 8:52 PM

If you follow the above method you will get the sequence in the field named name

Luis Jacobo
7/22/18, 10:19 AM

Im using a module to print the maintenance request, is a qweb report using the fields of the doc itself. I can call the equipment id, priority, and so on just adding the field name to the variable doc. (doc.equipment _id).

"<span t-field="doc.equipment_id.name"/>"

is this qweb report, how can call the sequence number of the current document?


Luis Jacobo
7/17/18, 2:26 PM

Hi Niyas,

My knowledge of programming is very basic, do i need to make those two files adapted to work with the maintenance model and install it from the web like any other module?


1 Comment
Niyas Raphy
7/17/18, 10:52 PM

See updated answer

Ask a Question
Keep Informed
1 follower(s)
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.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now