Chained Swapper
chained_swapper · OCA/server-ux
-
Security25/25No findings
-
Activity12/25Last human commit 17 months ago
-
Required by5/250 modules depend on it
-
Maturity25/25In 5 Odoo series since 12.0
Heuristic over the facts below, not an audit · How it's computed
Migration considerations
ChainedSwapper— Migrating to 19.0: `_sql_constraints` is ignored and its constraints are silently not created: declare `models.Constraint` attributes instead. migration-sql-constraints · source
Migration review checklist, not a compatibility verdict. "Migrating to X.0" applies once you upgrade to that version; "Since X.0" means this version already ignores or rejects that code. Methodology
Description
This module allows to swap the value of a field and propagate it in a chained way to linked records. Example: changing the delivery address in a confirmed sales order, it should be changed in its delivery orders as well.
It also allows to apply constraints for not allowing to do that change according rules, so the business logic is not broken. Example: Don't allow to change the delivery address if the delivery order is validated.
This module requires some technical knowledge for setting the chained swap and the constraint, as it's defined through technical names and Python code.
WARNING: Use this module with care, as it can screw up database consistency if swaps are not properly designed .
Dependencies
- Odoo dependencies
-
odoo/odoo:- base
- Python dependencies
- None
- System dependencies
- None
- Required by
- None
Code analysis
Extracted from the source by best-effort static analysis (no code is executed); details may be incomplete.
Views touched 6
| XML ID | Name | Model | Type | Status |
|---|---|---|---|---|
chained_swapper_constraint_view_form |
chained.swapper.constraint.form | chained.swapper.constraint | form | New |
chained_swapper_constraint_view_tree |
chained.swapper.constraint.tree | chained.swapper.constraint | list | New |
chained_swapper_sub_field_view_tree |
chained.swapper.sub.field.tree | chained.swapper.sub.field | list | New |
chained_swapper_view_form |
chained.swapper.form | chained.swapper | form | New |
chained_swapper_view_tree |
chained.swapper.tree | chained.swapper | list | New |
chained_swapper_wizard_view_form |
chained.swapper.wizard.form | chained.swapper.wizard | form | New |
HTTP endpoints 0
No HTTP endpoints found for this module.
Models touched 4
-
allowed_field_ids_domainBinarycompute='_compute_allowed_field_ids_domain' -
constraint_idsOne2many → chained.swapper.constraintcomodel_name='chained.swapper.constraint'inverse_name='chained_swapper_id'string='Constraints' -
field_idMany2one → ir.model.fieldscomodel_name='ir.model.fields'domain='allowed_field_ids_domain'ondelete='cascade'required=True -
group_idsMany2many → res.groupscolumn1='mass_id'column2='group_id'comodel_name='res.groups'relation='mass_group_rel'string='Groups' -
model_idMany2one → ir.modelcomodel_name='ir.model'help='Model is used for Selecting Field. This is editable until Contextual Action is not created.'ondelete='cascade'required=True -
nameCharindex=1required=Truetranslate=True -
ref_ir_act_window_idMany2one → ir.actions.act_windowcomodel_name='ir.actions.act_window'help='Action to make this template available on records of the related document model.'readonly=Truestring='Action' -
sub_field_idsOne2many → chained.swapper.sub.fieldcomodel_name='chained.swapper.sub.field'inverse_name='chained_swapper_id'string='Sub-fields'
-
add_action(self) -
unlink(self) -
unlink_action(self) -
write(self, vals)
-
chained_swapper_idMany2one → chained.swappercomodel_name='chained.swapper'ondelete='cascade' -
expressionTextdefault='True'help="Boolean python expression. You can use the keyword 'records' as the records selected to execute the contextual action. Ex.: bool(records.mapped('parent_id'))"required=Truestring='Constraint expression' -
nameCharrequired=Truetranslate=True
No public methods.
-
chained_swapper_idMany2one → chained.swappercomodel_name='chained.swapper'ondelete='cascade' -
model_nameCharrelated='chained_swapper_id.model_id.model'string='Model Name' -
sub_field_chainCharhelp="You can specify here a field of related fields as dotted names. Ex.: 'child_ids.lang'."required=True
No public methods.
-
company_idMany2one → res.companydefault=<expr>string='Company' args: 'res.company'
-
change_action(self) -
create(self, vals_list)@api.model_create_multiAs we don't have any field in this model, the key-value pair received in vals dict are only used to change the value in the active models. -
default_get(self, fields)@api.model -
fields_get(self, allfields=None, attributes=None)@api.model -
get_view(self, view_id=None, view_type='form', **options)@api.modelAs we don't have any field in this model, result['fields'] and result['arch'] are modified to add dynamically the corresponding field. -
get_views(self, views, options=None)@api.model -
onchange(self, values, field_names, fields_spec) -
post_chained_swap(self, model, field_name, original_values, new_value)@api.model -
read(self, fields, load='_classic_read')Without this call, dynamic fields build by get_view() generate a crash and warning, i.e.: read() with unknown field 'myfield'
Loading…
Loading…
Loading…
Loading…