-
- Downloads
[IMP] various: improve section and add note on sale order and invoice
The goal is to be able to more easily create section and notes on sale order, invoice, and quote. ================================ Problems of the existing feature ================================ The problematic part in the existing feature was that the same section had to be defined again and again for every line, instead of being defined only once where it needed to be. There was also no easy way to move them. Those concerns are solved here. Moreover, due to the complexity of the feature, it was hidden by default, requiring a setting and multiple overrides. The new feature is simple enough that it will always be present. ================== New implementation ================== Sections are lines solely used for display purpose, there is no business logic attached to them. They will show as a nice header at the top of the section, and a subtotal at the bottom of the section. We also take the opportunity to add notes, which are just like sections except they are displayed differently and don't include a subtotal. ========= Reasoning ========= We decided to implement it this way, as opposed to creating a proper section model, because it creates less changes in the code. Creating a intermediary section model between the sale order/invoice/quote and their lines would have required to rewrite the entirety of the code associated to them. It would also have required to create a new JS widget to handle on the same view a double-level One2many (or a One2many + group by). The current solution is much easier because it just requires adding 2 buttons, 1 simple field on the corresponding models which even has a NULL default value, and making some business checks (don't apply business to section/note). We tried our best to impact as less as possible the existing models. Notably we didn't want to add any extra field if this was avoidable. This also makes the migration easier. No matter the implementation choice the views/reports had to be updated to display the sections and notes correctly, which has been done. =========== Limitations =========== The current solution has several limitations: * since the sections don't have business logic, it's not possible to make any reporting based on them * any business related to sections has to be computed on the fly by browsing in order all of the lines, notably the subtotal has to be computed on the fly at every display - when sections are moved (drag&drop) on the back-end, the following lines that are part of the section are not moving with the section =========== Technically =========== The commit will: * update the models to add the display_type field (along with related sql constraints to guarantee integrity) * add new buttons at the bottom of the lists to allow creating section and note, along with the existing add a line/product button * add some business checks to not apply business to section/note (product_id and account_id became non-required fields) !!! The most likely cause of potential bugs introduced in this commit would be to have forgotten to add those checks on some places where they would be needed. This is tedious to check but fortunately easy to fix. * update the views to display sections and notes correctly, also made various improvements/fixes to those views (notably to apply B2B/B2C setting more consistently) !!! This is the second likely cause of potential bugs: if the updated views are inherited in a way that is not compatible with the changes. Or if we forgot to apply the changes to some other views. Again this is tedious to check but fortunately easy to fix. Task #53996 PR #25209
Showing
- addons/account/models/account_invoice.py 34 additions, 4 deletionsaddons/account/models/account_invoice.py
- addons/account/report/account_invoice_report.py 5 additions, 3 deletionsaddons/account/report/account_invoice_report.py
- addons/account/static/src/js/section_and_note_fields_backend.js 194 additions, 0 deletions.../account/static/src/js/section_and_note_fields_backend.js
- addons/account/static/src/scss/section_and_note_backend.scss 17 additions, 0 deletionsaddons/account/static/src/scss/section_and_note_backend.scss
- addons/account/views/account.xml 4 additions, 0 deletionsaddons/account/views/account.xml
- addons/account/views/account_invoice_view.xml 94 additions, 28 deletionsaddons/account/views/account_invoice_view.xml
- addons/account/views/report_invoice.xml 86 additions, 80 deletionsaddons/account/views/report_invoice.xml
- addons/l10n_in/views/report_invoice.xml 45 additions, 84 deletionsaddons/l10n_in/views/report_invoice.xml
- addons/l10n_in_sale/views/report_invoice_view.xml 0 additions, 114 deletionsaddons/l10n_in_sale/views/report_invoice_view.xml
- addons/l10n_in_sale/views/report_sale_order.xml 2 additions, 2 deletionsaddons/l10n_in_sale/views/report_sale_order.xml
- addons/report_intrastat/report/report_intrastat_invoice_template.xml 78 additions, 29 deletions...rt_intrastat/report/report_intrastat_invoice_template.xml
- addons/sale/__manifest__.py 0 additions, 2 deletionsaddons/sale/__manifest__.py
- addons/sale/data/sale_data.xml 0 additions, 14 deletionsaddons/sale/data/sale_data.xml
- addons/sale/models/__init__.py 0 additions, 1 deletionaddons/sale/models/__init__.py
- addons/sale/models/account_invoice.py 2 additions, 26 deletionsaddons/sale/models/account_invoice.py
- addons/sale/models/res_config_settings.py 0 additions, 1 deletionaddons/sale/models/res_config_settings.py
- addons/sale/models/res_users.py 0 additions, 5 deletionsaddons/sale/models/res_users.py
- addons/sale/models/sale.py 43 additions, 46 deletionsaddons/sale/models/sale.py
- addons/sale/models/sale_layout.py 0 additions, 14 deletionsaddons/sale/models/sale_layout.py
- addons/sale/report/invoice_report_templates.xml 0 additions, 147 deletionsaddons/sale/report/invoice_report_templates.xml
Loading
Please register or sign in to comment