diff --git a/partner_identification/models/res_partner_id_category.py b/partner_identification/models/res_partner_id_category.py index 6a04a8b86..aab64ac9b 100644 --- a/partner_identification/models/res_partner_id_category.py +++ b/partner_identification/models/res_partner_id_category.py @@ -33,21 +33,9 @@ class ResPartnerIdCategory(models.Model): ) active = fields.Boolean(string="Active", default=True) validation_code = fields.Text( - "Python validation code", - help="Python code called to validate an id number.", - default=lambda self: self._default_validation_code(), + "Python validation code", help="Python code called to validate an id number." ) - def _default_validation_code(self): - return _( - "\n# Python code. Use failed = True to specify that the id " - "number is not valid.\n" - "# You can use the following variables :\n" - "# - self: browse_record of the current ID Category " - "browse_record\n" - "# - id_number: browse_record of ID number to validate" - ) - def _validation_eval_context(self, id_number): self.ensure_one() return {"self": self, "id_number": id_number} diff --git a/partner_identification/models/res_partner_id_number.py b/partner_identification/models/res_partner_id_number.py index c5c3d7fe3..22323e9aa 100644 --- a/partner_identification/models/res_partner_id_number.py +++ b/partner_identification/models/res_partner_id_number.py @@ -68,3 +68,14 @@ class ResPartnerIdNumber(models.Model): ] ) active = fields.Boolean(string="Active", default=True) + + @api.model + def default_get(self, fields): + res = super(ResPartnerIdNumber, self).default_get(fields) + # It seems to be a bug in native odoo that the field partner_id + # is not in the fields list by default. A workaround is required + # to force this. + if "default_partner_id" in self._context and "partner_id" not in fields: + fields.append("partner_id") + res["partner_id"] = self._context.get("default_partner_id") + return res diff --git a/partner_identification/views/res_partner_id_category_view.xml b/partner_identification/views/res_partner_id_category_view.xml index d9763608b..78952e71c 100644 --- a/partner_identification/views/res_partner_id_category_view.xml +++ b/partner_identification/views/res_partner_id_category_view.xml @@ -7,10 +7,38 @@ form
- - - - + + + + + + + + + + + +