Hi,
how can i assign a number id to every maintenance request created?
Im using the Equipment module on Odoo 10.
Thks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
how can i assign a number id to every maintenance request created?
Im using the Equipment module on Odoo 10.
Thks
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
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
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
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
See updated answer
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
Jan 24
|
490 | ||
|
2
Dec 23
|
467 | ||
|
1
Dec 23
|
428 | ||
|
1
Jun 23
|
879 | ||
|
1
Jun 23
|
3564 |