Skip to Content
Menu
This question has been flagged
2 Replies
1037 Views

Hello I want to create a button to publish job offers on web site 

Error : AttributeError: type object 'recrutement.offre_d_emploi' has no attribute 'open_website_url'

this is ma code :

class Offre_D_emploi(models.Model):
_name = "recrutement.offre_d_emploi"
_rec_name = "reference"

reference = fields.Integer(string="Référence")
titre_poste = fields.Char(String="Titre de poste")
nom_societé = fields.Char(String="Nom de la societé")
localité = fields.Char(String="Localité")
parent_id = fields.Many2one('hr.department', string="Departement")
description_poste = fields.Text(String="Description Poste")
exigences = fields.Char(String="Exigences")
date_debut = fields.Date(string="Date Début")
avantages = fields.Char(string="Avantages")
date_fin_d_offre = fields.Date(string="Date fin d'offre")
website_published = fields.Boolean('Visible on current website', related='is_published', readonly=False)
is_published = fields.Boolean('Is Published', copy=False, default=lambda self: self._default_is_published())
can_publish = fields.Boolean('Can Publish', compute='_compute_can_publish')
website_url = fields.Char('Website URL', compute='_compute_website_url', help='The full URL to access the document through the website.')

def _compute_website_url(self):
for job in self:
job.website_url = "/jobs/detail/%s" % job.id

def set_open(self):
self.write({'website_published': False})
return self.website_url

==================================================================================


<record id="offre_form" model="ir.ui.view">
<field name="name">recrutement.offre_d_emploi.form</field>
<field name="model">recrutement.offre_d_emploi</field>
<field name="arch" type="xml">
<form string="Offres d'emploi">
<sheet>
<h1> Publication d'offre d'emploi :
</h1>
<div name="button_box" position="inside">
<field name="is_published" widget="website_redirect_button"/>
</div>
<group>
<field name="reference"/>
<field name="titre_poste"/>
</group>
<group>
<field name="nom_societé"/>
<field name="localité"/>
</group>
<group>
<field name="parent_id"/>
<field name="description_poste"/>
</group>
<group>
<field name="exigences"/>
<field name="date_debut"/>
<field name="avantages"/>
<field name="date_fin_d_offre"/>
</group>
</sheet>
</form>
</field>
</record>

Avatar
Discard
Best Answer

Hi geeksdata,

Error which you face is searching for the open_website_url method. So In odoo base we have the model "website.published.mixin" that contains the method open_website_url()

and to use this method in your current object you can inherit this model or you can define the method open_website_url() in your model according to your requirement.

class Offre_D_emploi(models.Model):

    _name = "recrutement.offre_d_emploi"

    _inherit = "website.published.mixin"

    _rec_name = "reference"

Hope this may help you!

Thanks

Regards,




Email:      odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   


Avatar
Discard
Author Best Answer

Bonjour, le probleme n'est pas résolut, lorsque j'ajoute l'héritation de  "website.published.mixin" il y'a aussi un autre probleme tel que : 

Erreur Interne du Serveur

Le serveur a rencontré une erreur interne et n'a pas pu terminer votre demande. Soit le serveur est surchargé, soit il y a une erreur dans l'application.

                      

Avatar
Discard