[IMP] hr_recruitment: Make the last job position used the default one at creation
task-3133112 closes odoo/odoo#123781 X-original-commit: 388cbee9537b460ef80401d3a33b258d761477c2 Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
@@ -13,14 +13,23 @@ class Job(models.Model):
|
||||
|
||||
@api.model
|
||||
def _default_address_id(self):
|
||||
return self.env.company.partner_id
|
||||
last_used_address = self.env['hr.job'].search([('company_id', 'in', self.env.companies.ids)], order='id desc', limit=1)
|
||||
if last_used_address:
|
||||
return last_used_address.address_id
|
||||
else:
|
||||
return self.env.company.partner_id
|
||||
|
||||
def _address_id_domain(self):
|
||||
return ['|', '&', '&', ('type', '!=', 'contact'), ('type', '!=', 'private'),
|
||||
('id', 'in', self.sudo().env.companies.partner_id.child_ids.ids),
|
||||
('id', 'in', self.sudo().env.companies.partner_id.ids)]
|
||||
|
||||
def _get_default_favorite_user_ids(self):
|
||||
return [(6, 0, [self.env.uid])]
|
||||
|
||||
address_id = fields.Many2one(
|
||||
'res.partner', "Job Location", default=_default_address_id,
|
||||
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",
|
||||
domain=lambda self: self._address_id_domain(),
|
||||
help="Address where employees are working")
|
||||
application_ids = fields.One2many('hr.applicant', 'job_id', "Job Applications")
|
||||
application_count = fields.Integer(compute='_compute_application_count', string="Application Count")
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
<label for="address_id"/>
|
||||
<div class="o_row">
|
||||
<span attrs="{'invisible': [('address_id', '!=', False)]}" class="oe_read_only">Remote</span>
|
||||
<field name="address_id" context="{'show_address': 1}" domain= "[('is_company', '=', True )]" options="{'always_reload': True}" placeholder="Remote"/>
|
||||
<field name="address_id" context="{'show_address': 1}" options="{'always_reload': True}" placeholder="Remote"/>
|
||||
</div>
|
||||
<label for="alias_name" string="Email Alias" attrs="{'invisible': [('alias_domain', '=', False)]}" help="Define a specific contact address for this job position. If you keep it empty, the default email address will be used which is in human resources settings"/>
|
||||
<div name="alias_def" attrs="{'invisible': [('alias_domain', '=', False)]}">
|
||||
|
||||
Reference in New Issue
Block a user