Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
4512 Tampilan

Hi, 

how can i assign a number id to every maintenance request created?


Im using the Equipment module on Odoo 10.


Thks

Avatar
Buang
Jawaban Terbai

Hi,

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"/>
</record>

Then,

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'))

@api.model
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


Thanks

Avatar
Buang
Penulis

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.

Thnks

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

Penulis

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?

thnks

Penulis Jawaban Terbai

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?


Thks

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Sep 25
1885
2
Jan 24
2127
2
Des 23
2075
1
Des 23
1886
1
Jun 23
2243