- Added comprehensive README files for all three sync modules - Implemented advanced logging system with multiple log levels (DEBUG, INFO, WARNING, ERROR) - Added automatic sensitive data masking for security in log payloads - Implemented log retention policy (90 days local, 7 years in AWS S3 Glacier) - Added AWS S3 integration for long-term log archiving - Fixed validation error with bemade_instance_id in sync model creation - Refactored model inheritance structure from _inherit to _inherits for proper delegation - Fixed duplicate sync model prevention logic - Restored Test Connection button in instance view - Fixed connection test logging to properly record success/failure - Fixed queue creation for connection test logs - Removed unnecessary Synchronized Module tab from odoo_to_odoo_bemade - Added database indexing on create_date for performance optimization - Fixed foreign key constraint violations in field mappings creation - Enhanced error handling throughout the synchronization process
84 lines
2.3 KiB
Python
84 lines
2.3 KiB
Python
from odoo import models, fields, api
|
|
|
|
class OdooSyncModelField(models.Model):
|
|
_name = 'odoo.sync.model.field'
|
|
_description = 'Synchronized Field'
|
|
_order = 'sequence, id'
|
|
|
|
sequence = fields.Integer(
|
|
string='Sequence',
|
|
default=10,
|
|
help='Used to order the field mappings'
|
|
)
|
|
|
|
model_sync_id = fields.Many2one(
|
|
comodel_name='odoo.sync.model',
|
|
string='Synchronized Model',
|
|
required=True,
|
|
ondelete='cascade'
|
|
)
|
|
|
|
field_id = fields.Many2one(
|
|
comodel_name='ir.model.fields',
|
|
string='Field',
|
|
domain="[('model_id', '=', parent.model_id)]",
|
|
required=True,
|
|
ondelete='cascade'
|
|
)
|
|
|
|
name = fields.Char(
|
|
related='field_id.name',
|
|
string='Technical Name',
|
|
store=True
|
|
)
|
|
|
|
source_field = fields.Char(
|
|
string='Source Field',
|
|
help='Field name in the source model'
|
|
)
|
|
|
|
target_field = fields.Char(
|
|
string='Target Field',
|
|
help='Field name in the target model'
|
|
)
|
|
|
|
transform_type = fields.Selection([
|
|
('direct', 'Direct'),
|
|
('function', 'Function'),
|
|
('relation', 'Relation')
|
|
], string='Transform Type', default='direct',
|
|
help='How to transform the field value during synchronization')
|
|
|
|
is_identifier = fields.Boolean(
|
|
string='Is Identifier',
|
|
default=False,
|
|
help='Whether this field is used to identify records'
|
|
)
|
|
|
|
active = fields.Boolean(
|
|
string='Active',
|
|
default=True
|
|
)
|
|
|
|
required = fields.Boolean(
|
|
string='Required',
|
|
default=False
|
|
)
|
|
|
|
sync_default = fields.Char(
|
|
string='Default Value',
|
|
help='Value to use if not available'
|
|
)
|
|
|
|
conflict_strategy = fields.Selection([
|
|
('source_wins', 'Source gagne'),
|
|
('dest_wins', 'Destination gagne'),
|
|
('newest', 'Plus récent'),
|
|
('manual', 'Résolution manuelle')
|
|
], default='newest', string='Stratégie de conflit',
|
|
help='Stratégie à utiliser pour résoudre les conflits de synchronisation sur ce champ')
|
|
|
|
_sql_constraints = [
|
|
('field_uniq', 'unique(model_sync_id, field_id)',
|
|
'Un champ ne peut être synchronisé qu\'une fois par modèle!')
|
|
]
|