Thursday, October 29, 2020
2 changes · master
Enhancements to existing features
This update introduces standardized names and helper functions for managing linked record lists, replacing hard-coded numeric commands across Odoo. It makes the code easier for developers to read and maintain while preserving compatibility with older frontend command names.
Original PR description
One2many and Many2many use a special "commands" format to manipulate the set of records stored in/linked to the field. There is a total of 7 commands: `create`, `update`, `delete`, `unlink`, `link`,…
One2many and Many2many use a special "commands" format to manipulate the set of records stored in/linked to the field. There is a total of 7 commands: `create`, `update`, `delete`, `unlink`, `link`, and `set`. * The `create` command (id: 0) is used to create a new record in the related model and to link it in the current record. * The `update` command (id: 1) is used to update the targeted record id with new values. * The `delete` command (id: 2) is used to both remove the target record id from the related table and to remove its link from the current record. * The `unlink` command (id: 3) is used to remove the link to the targeted record id from the current record. * The `link` command (id: 4) is used to link the targeted record id which exists already in the related model in the current record. * The `clear` command (id: 5) is used to empty the list of linked record ids. * The `set` command (id: 6) is used to replace the list of linked record ids with the provided. Each command is a tuple with up to 3 elements, the second and/or third element is ignored when it is not applicable to the command: 1) the mandatory command identifier 2) the targeted record id (1, 2, 3, 4) 3) create/write values dictionary (0, 1) or target record ids (6) -- Before this contribution, the several commands did not have a standardized name, the tuples were just hard-coded with the integer identifier. For long developers have been complaining the commands were hard to write and hard to read mainly due to the meaningless integer. This contribution provide a new namespace with the constants and functions desired to ease writting and reading the X2Many commands. All modules have been updated to use the new constants instead of the integer identifier. On the frontend side, such constants (in the form of strings) do exist already but do not conform to the new standardized names. It has been decided to enforce the new nomenclature but to provide aliases to the old names to ensure a better compatibility. Task: 2366606
This change standardizes the way Odoo code refers to commands that update linked records, replacing hard-coded numbers with clear names. It improves maintainability and reduces the risk of developer mistakes, while preserving compatibility with older frontend command names.
Original PR description
One2many and Many2many use a special "commands" format to manipulate the set of records stored in/linked to the field. There is a total of 7 commands: `create`, `update`, `delete`, `unlink`, `link`,…
One2many and Many2many use a special "commands" format to manipulate the set of records stored in/linked to the field. There is a total of 7 commands: `create`, `update`, `delete`, `unlink`, `link`, and `set`. * The `create` command (id: 0) is used to create a new record in the related model and to link it in the current record. * The `update` command (id: 1) is used to update the targeted record id with new values. * The `delete` command (id: 2) is used to both remove the target record id from the related table and to remove its link from the current record. * The `unlink` command (id: 3) is used to remove the link to the targeted record id from the current record. * The `link` command (id: 4) is used to link the targeted record id which exists already in the related model in the current record. * The `clear` command (id: 5) is used to empty the list of linked record ids. * The `set` command (id: 6) is used to replace the list of linked record ids with the provided. Each command is a tuple with up to 3 elements, the second and/or third element is ignored when it is not applicable to the command: 1) the mandatory command identifier 2) the targeted record id (1, 2, 3, 4) 3) create/write values dictionary (0, 1) or target record ids (6) -- Before this contribution, the several commands did not have a standardized name, the tuples were just hard-coded with the integer identifier. For long developers have been complaining the commands were hard to write and hard to read mainly due to the meaningless integer. This contribution provide a new namespace with the constants and functions desired to ease writting and reading the X2Many commands. All modules have been updated to use the new constants instead of the integer identifier. On the frontend side, such constants (in the form of strings) do exist already but do not conform to the new standardized names. It has been decided to enforce the new nomenclature but to provide aliases to the old names to ensure a better compatibility. Task: 2366606