hi all , iam trying to get the sequence for the employees in hr_module , but when i create a employee it shows NEW instead of the sequence EMP_
hr.py :
name_seq = fields.Char(string='Order Reference', required=True, copy=False, readonly=True, index=True, default=lambda self: _('New'))
@api.model
def create(self, vals):
if vals.get('name_seq', _('New')) == _('New'):
vals['name_seq'] = self.env['ir.sequence'].next_by_code('hr.employee.sequence', sequence_date=seq_date) or _('New')
result = super(HrEmployeePrivate, self).create(vals)
return result
sequence.xml:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!-- Sequences for transfer.order -->
<record id="seq_hr_employee" model="ir.sequence">
<field name="name">Employee Sequence</field>
<field name="code">hr.employee.sequence</field>
<field name="prefix">EMP</field>
<field name="padding">3</field>
<field name="company_id" eval="False"/>
</record>
</data>
</odoo>
hr_views.xml :
<div class="oe_title">
<h1>
<field name="name_seq" readonly ="1"/>
</h1>
<h2>
<field name="name" placeholder="Employee's Name" required="True"/>
</h2>
<h3>
<field name="job_title" placeholder="Job Position" />
</h3>
<field name="category_ids" widget="many2many_tags" options="{'color_field': 'color', 'no_create_edit': True}" placeholder="Tags" groups="hr.group_hr_manager"/>
</div>
hr.py :
name_seq = fields.Char(string='Order Reference', required=True, copy=False, readonly=True, index=True, default=lambda self: _('New'))
@api.model
def create(self, vals):
if vals.get('name_seq', _('New')) == _('New'):
vals['name_seq'] = self.env['ir.sequence'].next_by_code('hr.employee.sequence', sequence_date=seq_date) or _('New')
result = super(HrEmployeePrivate, self).create(vals)
return result
sequence.xml:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!-- Sequences for transfer.order -->
<record id="seq_hr_employee" model="ir.sequence">
<field name="name">Employee Sequence</field>
<field name="code">hr.employee.sequence</field>
<field name="prefix">EMP</field>
<field name="padding">3</field>
<field name="company_id" eval="False"/>
</record>
</data>
</odoo>
hr_views.xml :
<div class="oe_title">
<h1>
<field name="name_seq" readonly ="1"/>
</h1>
<h2>
<field name="name" placeholder="Employee's Name" required="True"/>
</h2>
<h3>
<field name="job_title" placeholder="Job Position" />
</h3>
<field name="category_ids" widget="many2many_tags" options="{'color_field': 'color', 'no_create_edit': True}" placeholder="Tags" groups="hr.group_hr_manager"/>
</div>