Skip to main content

Chained Swapper

Project description

Beta License: AGPL-3 OCA/server-ux Translate me on Weblate Try me on Runbot

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 .

Table of contents

Configuration

To configure this module, you need to:

  1. Go to Setting > Field Swaps > Field Swaps.

  2. Create a new object and set the following data as an example:

    • Name for identifying it and use it for the action name.

    • Select the source model where the swap will be started.

    • Select the starting field for which the swap will be done.

    • Add several chained fields. They are expressed as a string using dot notation, taking the source model as beginning for looking there the first field, and continuing from there drilling through. Example: picking_ids.partner_id for sale.order model will go to the linked deliveries orders, and change the customer there.

    • Add possible constraints for restricting the chained swap. They are Python expressions that must be one line that is evaluated as boolean. If the evaluation is true, then a message will be thrown and no swap will be allowed. You can use the variable records in your code, that will be referring the selected records for doing the swap. Example: for restricting sales orders that have a delivery order validated:

      any(p.state == ‘done’ for p in records.mapped(‘picking_ids.state’))

      Other variables you can use are env, date and datetime. Each constraint has a name for identifying it, but also for showing that name when displaying the error trying to do the swap.

  3. Click on ‘Add action’ smart button to add a new action in the source model.

On demo databases, you can check the example “Language”, that changes the language of a contact, and propagate it to children contacts.

Usage

To use this module, you need to:

  1. Go to the source document in list mode.

  2. Select one or several records.

  3. Click on Action and locate the option “Chained swap: <name of the swap>”.

  4. If one of the selected records doesn’t comply with one of the constraints, a message will be shown, and the swap won’t continue.

  5. If everything is OK, a popup will arise, and you will see a field for filling the new value.

  6. Click on “Change”, and the swap will be done.

  7. On the chatter of the source document, an entry will be logged for reflecting the done swap.

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits

Authors

  • Tecnativa

Contributors

Maintainers

This module is maintained by the OCA.

Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

This module is part of the OCA/server-ux project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file odoo12_addon_chained_swapper-12.0.1.0.0.99.dev4-py3-none-any.whl.

File metadata

File hashes

Hashes for odoo12_addon_chained_swapper-12.0.1.0.0.99.dev4-py3-none-any.whl
Algorithm Hash digest
SHA256 224d03526b32139c11f93f8f7401c04bfdf2c3e8158df0dd8f000dd57dbba577
MD5 9b25fe0778a40b2d2b25199f62c2aa5b
BLAKE2b-256 1ffb77b3db3b05eeec32e53336c5cc3b5ddf0fdb30f7cafce4cb4d7483158474

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page