i want to link 2 models of 2 diffrent addons i put one of them in the depends listin the manifest file but i had an error:
here is the code:
class Employee(models.Model):
_name = 'prof.zaouia.employee'
image = fields.Binary()
name = fields.Char(string='Nom', required=True)
prenom = fields.Char(string='Prénom', required=True)
charge = fields.Integer(string='personnes à charge', required=True)
situation = fields.Selection([('M', 'M'), ('C', 'C')], default='M')
nombre_jours = fields.Integer(string='nombre de jours travaillés', default=26)
periode = fields.Date(string='salaire au', default=fields.Date.today())
nationality = fields.Many2one(string='Nationalité', comodel_name='prof.zaouia.nationality')
salaire_brutm = fields.Float(string='Salaire brut mensuel')
salaire_bdu = fields.Float(string='Salaire brut dû', compute='_compute_salaire_bdu', store=True)
specializations = fields.Many2one(string='Métier', comodel_name='prof.zaouia.specialization')
reservation_id = fields.Many2one(comodel_name="roombooking", string="responsable for")
class RoomBooking(models.Model):
_name = "roombooking"
booking_id = fields.Integer("booking_ID")
checkInDate = fields.Date("check_in")
checkoutDate = fields.Date("check_out")
payement_status = fields.Boolean("payement_status")
totale_amount = fields.Float("total")
rooms = fields.One2many("room", "roombooking_id", string="rooms")
client_id = fields.Many2one("client", string="client")
responsables = fields.One2many(comodel_name = "prof.zaouia.employee", inverse_name = "reservation_id", String="responsables")
here is the error:
RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
File "C:\Users\hossa\odoo\odoo\http.py", line 1584, in _serve_db
return service_model.retrying(self._serve_ir_http, self.env)
File "C:\Users\hossa\odoo\odoo\service\model.py", line 134, in retrying
result = func()
File "C:\Users\hossa\odoo\odoo\http.py", line 1611, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "C:\Users\hossa\odoo\odoo\http.py", line 1808, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
File "C:\Users\hossa\odoo\odoo\addons\base\models\ir_http.py", line 149, in _dispatch
result = endpoint(**request.params)
File "C:\Users\hossa\odoo\odoo\http.py", line 699, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "c:\users\hossa\odoo\addons\web\controllers\dataset.py", line 42, in call_kw
return self._call_kw(model, method, args, kwargs)
File "c:\users\hossa\odoo\addons\web\controllers\dataset.py", line 33, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "C:\Users\hossa\odoo\odoo\api.py", line 461, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "C:\Users\hossa\odoo\odoo\api.py", line 448, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "C:\Users\hossa\odoo\odoo\models.py", line 6475, in onchange
record._update_cache(changed_values, validate=False)
File "C:\Users\hossa\odoo\odoo\models.py", line 5274, in _update_cache
value = field.convert_to_cache(value, self, validate)
File "C:\Users\hossa\odoo\odoo\fields.py", line 2965, in convert_to_cache
id_ = comodel.new(value, origin=origin).id
File "C:\Users\hossa\odoo\odoo\models.py", line 5665, in new
origin = origin.id
AttributeError: '_unknown' object has no attribute 'id'
The above server error caused the following client error:
null
i tries to add the other addons in the the other depends list on the manifest file but i hade an error i tryed to add an id attribute but it didn't work too
That won't work with both modules using each others model with only one depending on the other. Instead just build up the one2many relation in one module with one dependency extending the others modules model, for example extending model
prof.zaouia.employee:So assuming model
prof.zaouia.employeebelongs to module1 androombookingto module2, than my code example is in module2 and module2 depends on module1.