Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
4523 Widoki

Hi, 

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


Im using the Equipment module on Odoo 10.


Thks

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

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

Autor

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

Autor Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
wrz 25
1917
2
sty 24
2162
2
gru 23
2104
1
gru 23
1913
1
cze 23
2258