|
@ -22,6 +22,15 @@ class ResPartner(models.Model): |
|
|
else: |
|
|
else: |
|
|
return '' |
|
|
return '' |
|
|
|
|
|
|
|
|
|
|
|
def _get_category_id(self): |
|
|
|
|
|
categories_list = '' |
|
|
|
|
|
for category in self.category_id : |
|
|
|
|
|
if categories_list != '': |
|
|
|
|
|
categories_list = categories_list + ', ' |
|
|
|
|
|
categories_list = categories_list + category.name |
|
|
|
|
|
return categories_list |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
############################################ |
|
|
############################################ |
|
|
#region Public method for JSON Serialization |
|
|
#region Public method for JSON Serialization |
|
@ -40,8 +49,12 @@ class ResPartner(models.Model): |
|
|
for field in export_fields: |
|
|
for field in export_fields: |
|
|
if field.name == "industry_id": |
|
|
if field.name == "industry_id": |
|
|
self._add_computed_node(element, "industry_id", self._get_industry_id_label) |
|
|
self._add_computed_node(element, "industry_id", self._get_industry_id_label) |
|
|
|
|
|
elif field.name == "category_id": |
|
|
|
|
|
_logger.warning("STEPHAN - Ajout des catégories") |
|
|
|
|
|
self._add_computed_node(element, "category_id", self._get_category_id) |
|
|
else: |
|
|
else: |
|
|
self._add_simple_node(element, field.name) |
|
|
self._add_simple_node(element, field.name) |
|
|
|
|
|
_logger.warning("STEPHAN - Retours des éléments") |
|
|
return element |
|
|
return element |
|
|
#endregion |
|
|
#endregion |
|
|
|
|
|
|
|
@ -55,10 +68,12 @@ class ResPartner(models.Model): |
|
|
export_fields = self.env['ir.model.fields'].search([('model_id', '=', 'res.partner'),('id','in', export_field_ids)]) |
|
|
export_fields = self.env['ir.model.fields'].search([('model_id', '=', 'res.partner'),('id','in', export_field_ids)]) |
|
|
return export_fields |
|
|
return export_fields |
|
|
|
|
|
|
|
|
|
|
|
# Method to add simple fields, for which there is no process needed |
|
|
def _add_simple_node(self, element, fieldName): |
|
|
def _add_simple_node(self, element, fieldName): |
|
|
if getattr(self, fieldName): |
|
|
if getattr(self, fieldName): |
|
|
element[fieldName] = self[fieldName] |
|
|
element[fieldName] = self[fieldName] |
|
|
|
|
|
|
|
|
|
|
|
# Method to add complex fileds, for which we need a dedicated method to get the value |
|
|
def _add_computed_node(self, element, fieldLabel, specificMethod): |
|
|
def _add_computed_node(self, element, fieldLabel, specificMethod): |
|
|
element[fieldLabel] = specificMethod() |
|
|
element[fieldLabel] = specificMethod() |
|
|
#endregion |
|
|
#endregion |
|
|