-
-
Notifications
You must be signed in to change notification settings - Fork 89
[18.0][ADD] Introduce Spreadsheet Quotation Calculator #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cifuentesmx
wants to merge
5
commits into
OCA:18.0
Choose a base branch
from
cifuentesmx:18.0
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
35534d0
[ADD] spreadsheet_quotation: Introduce Spreadsheet Quotation Calculator
6fa18b2
[REF] Refactor code for readability and consistency
86b1064
[ADD] Add images and update usage documentation for spreadsheet quota…
49f9aa9
Fix link for spreadsheet_quotation in README.md to point to the corre…
b660d0e
Merge branch 'OCA:18.0' into 18.0
cifuentesmx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| .. image:: https://odoo-community.org/readme-banner-image | ||
| :target: https://odoo-community.org/get-involved?utm_source=readme | ||
| :alt: Odoo Community Association | ||
|
|
||
| =============================== | ||
| Spreadsheet Quotation Calculator | ||
| =============================== | ||
|
|
||
| |badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
|
||
| .. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png | ||
| :target: https://odoo-community.org/page/development-status | ||
| :alt: Alpha | ||
| .. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png | ||
| :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
| :alt: License: AGPL-3 | ||
| .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fspreadsheet-lightgray.png?logo=github | ||
| :target: https://github.com/OCA/spreadsheet/tree/18.0/spreadsheet_quotation | ||
| :alt: OCA/spreadsheet | ||
| .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
| :target: https://translation.odoo-community.org/projects/spreadsheet-18-0/spreadsheet-18-0-spreadsheet_quotation | ||
| :alt: Translate me on Weblate | ||
| .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
| :target: https://runboat.odoo-community.org/builds?repo=OCA/spreadsheet&target_branch=18.0 | ||
| :alt: Try me on Runboat | ||
|
|
||
| This module allows linking spreadsheet calculators to quotation templates | ||
| in Odoo. When a sale order is created from a template that has a | ||
| calculator, a copy of the spreadsheet is automatically assigned to the | ||
| order with a pre-configured global filter so the ``ODOO.LIST`` formulas | ||
| display only that order's lines. | ||
|
|
||
| The spreadsheet calculator is built on top of ``spreadsheet_oca`` and | ||
| uses ``ODOO.LIST`` formulas to display sale order line data such as | ||
| product, quantity, and unit price. A Field Sync side panel lets users map | ||
| spreadsheet columns to sale order line fields and push calculated values | ||
| back to the quotation. | ||
|
|
||
| **Table of contents** | ||
|
|
||
| .. contents:: | ||
| :local: | ||
|
|
||
| Installation | ||
| ============ | ||
|
|
||
| This module requires: | ||
|
|
||
| - ``spreadsheet_oca`` from the OCA spreadsheet repository | ||
| - ``sale_management`` from Odoo core addons | ||
|
|
||
| Usage | ||
| ===== | ||
|
|
||
| Setting up a quotation calculator | ||
| --------------------------------- | ||
|
|
||
| 1. Go to **Sales > Configuration > Quotation Templates**. | ||
| 2. Open or create a quotation template. | ||
| 3. Click **Create Calculator** next to the quotation calculator field. | ||
| 4. Set a name and the initial number of rows in the wizard. | ||
| 5. Customize the spreadsheet and save it. | ||
|
|
||
| Using the calculator on a sale order | ||
| ------------------------------------ | ||
|
|
||
| 1. Create a new quotation and select a template with a calculator. | ||
| 2. Use the **Calculator** smart button to open the spreadsheet. | ||
| 3. Edit values in the spreadsheet. | ||
| 4. Use **Field Sync** to map columns to sale order line fields. | ||
| 5. Save the spreadsheet to sync values back to the sale order. | ||
|
|
||
| Bug Tracker | ||
| =========== | ||
|
|
||
| Bugs are tracked on `GitHub Issues <https://github.com/OCA/spreadsheet/issues>`_. | ||
| In case of trouble, please check there if your issue has already been reported. | ||
| If you spotted it first, help us to smash it by providing detailed and welcomed | ||
| `feedback <https://github.com/OCA/spreadsheet/issues/new?body=module:%20spreadsheet_quotation%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
|
||
| Do not contact contributors directly about support or help with technical issues. | ||
|
|
||
| Credits | ||
| ======= | ||
|
|
||
| Authors | ||
| ------- | ||
|
|
||
| * Odoo Community Association (OCA) | ||
| * Cloud Lotus | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| * OCA Contributors | ||
|
|
||
| Maintainers | ||
| ----------- | ||
|
|
||
| This module is maintained by the OCA. | ||
|
|
||
| .. image:: https://odoo-community.org/logo.png | ||
| :alt: Odoo Community Association | ||
| :target: https://odoo-community.org | ||
|
|
||
| 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/spreadsheet <https://github.com/OCA/spreadsheet/tree/18.0/spreadsheet_quotation>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. To learn how please visit | ||
| https://odoo-community.org/page/Contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Copyright 2026 Odoo Community Association (OCA) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| from . import models | ||
| from . import wizards |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Copyright 2026 Odoo Community Association (OCA) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| { | ||
| "name": "Spreadsheet Quotation Calculator", | ||
| "summary": ( | ||
| "Use spreadsheets as quotation calculators linked " "to sale order templates" | ||
| ), | ||
| "version": "18.0.1.0.0", | ||
| "license": "AGPL-3", | ||
| "author": "Odoo Community Association (OCA), Cloud Lotus", | ||
| "website": "https://github.com/OCA/spreadsheet", | ||
| "depends": ["spreadsheet_oca", "sale_management"], | ||
| "data": [ | ||
| "security/ir.model.access.csv", | ||
| "wizards/spreadsheet_quotation_create.xml", | ||
| "views/sale_order_template_views.xml", | ||
| "views/sale_order_views.xml", | ||
| ], | ||
| "assets": { | ||
| "spreadsheet.o_spreadsheet": [ | ||
| "spreadsheet_quotation/static/src/quotation_spreadsheet/field_sync_plugin.esm.js", | ||
| "spreadsheet_quotation/static/src/quotation_spreadsheet/field_sync_side_panel.esm.js", | ||
| "spreadsheet_quotation/static/src/quotation_spreadsheet/field_sync_side_panel.xml", | ||
| "spreadsheet_quotation/static/src/quotation_spreadsheet/quotation_spreadsheet.xml", | ||
| ], | ||
| }, | ||
| "installable": True, | ||
| "development_status": "Alpha", | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Copyright 2026 Odoo Community Association (OCA) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| from . import sale_order_template | ||
| from . import sale_order |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # Copyright 2026 Odoo Community Association (OCA) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| import json | ||
|
|
||
| from odoo import _, api, fields, models | ||
|
|
||
|
|
||
| class SaleOrder(models.Model): | ||
| _inherit = "sale.order" | ||
|
|
||
| spreadsheet_id = fields.Many2one( | ||
| "spreadsheet.spreadsheet", | ||
| string="Quotation Calculator", | ||
| copy=False, | ||
| ) | ||
| has_spreadsheet = fields.Boolean( | ||
| compute="_compute_has_spreadsheet", | ||
| ) | ||
|
|
||
| @api.depends("spreadsheet_id") | ||
| def _compute_has_spreadsheet(self): | ||
| for order in self: | ||
| order.has_spreadsheet = bool(order.spreadsheet_id) | ||
|
|
||
| @api.onchange("sale_order_template_id") | ||
| def _onchange_sale_order_template_id_spreadsheet(self): | ||
| if self.sale_order_template_id and self.sale_order_template_id.spreadsheet_id: | ||
| spreadsheet = self._copy_template_spreadsheet( | ||
| self.sale_order_template_id.spreadsheet_id, | ||
| ) | ||
| self.spreadsheet_id = spreadsheet | ||
| elif not self.sale_order_template_id: | ||
| self.spreadsheet_id = False | ||
|
|
||
| def _copy_template_spreadsheet(self, template_spreadsheet): | ||
| """Create a copy of the template spreadsheet for this sale order.""" | ||
| return template_spreadsheet.copy( | ||
| {"name": _("Calculator - %s", self.name or _("New"))} | ||
| ) | ||
|
|
||
| def _update_spreadsheet_filter(self): | ||
| """Update the global filter default value in the spreadsheet JSON | ||
| so the list is filtered to this sale order's id.""" | ||
| self.ensure_one() | ||
| if not self.spreadsheet_id: | ||
| return | ||
| data = self.spreadsheet_id.spreadsheet_raw | ||
| if not data: | ||
| return | ||
| if isinstance(data, str): | ||
| data = json.loads(data) | ||
|
|
||
| for gf in data.get("globalFilters", []): | ||
| if gf.get("type") == "relation" and gf.get("modelName") == "sale.order": | ||
| gf["defaultValue"] = [self.id] | ||
| break | ||
|
|
||
| self.spreadsheet_id.spreadsheet_raw = data | ||
|
|
||
| def write(self, vals): | ||
| res = super().write(vals) | ||
| if "spreadsheet_id" in vals: | ||
| for order in self.filtered("spreadsheet_id"): | ||
| order._update_spreadsheet_filter() | ||
| return res | ||
|
|
||
| @api.model_create_multi | ||
| def create(self, vals_list): | ||
| orders = super().create(vals_list) | ||
| for order in orders.filtered("spreadsheet_id"): | ||
| order._update_spreadsheet_filter() | ||
| return orders | ||
|
|
||
| def action_open_spreadsheet_calculator(self): | ||
| self.ensure_one() | ||
| if self.spreadsheet_id: | ||
| return self.spreadsheet_id.open_spreadsheet() | ||
| return False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Copyright 2026 Odoo Community Association (OCA) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class SaleOrderTemplate(models.Model): | ||
| _inherit = "sale.order.template" | ||
|
|
||
| spreadsheet_id = fields.Many2one( | ||
| "spreadsheet.spreadsheet", | ||
| string="Quotation Calculator", | ||
| copy=True, | ||
| help="Spreadsheet used as pricing calculator for quotations " | ||
| "created from this template.", | ||
| ) | ||
|
|
||
| def action_create_spreadsheet_calculator(self): | ||
| self.ensure_one() | ||
| return { | ||
| "type": "ir.actions.act_window", | ||
| "name": "Create Quotation Calculator", | ||
| "res_model": "spreadsheet.quotation.create", | ||
| "view_mode": "form", | ||
| "target": "new", | ||
| "context": { | ||
| "default_sale_order_template_id": self.id, | ||
| }, | ||
| } | ||
|
|
||
| def action_open_spreadsheet_calculator(self): | ||
| self.ensure_one() | ||
| if self.spreadsheet_id: | ||
| return self.spreadsheet_id.open_spreadsheet() | ||
| return self.action_create_spreadsheet_calculator() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [build-system] | ||
| requires = ["whool"] | ||
| build-backend = "whool.buildapi" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * OCA Contributors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| This module allows linking spreadsheet calculators to quotation templates | ||
| in Odoo. When a sale order is created from a template that has a | ||
| calculator, a copy of the spreadsheet is automatically assigned to the | ||
| order with a pre-configured global filter so the ODOO.LIST formulas | ||
| display only that order's lines. | ||
|
|
||
| The spreadsheet calculator is built on top of ``spreadsheet_oca`` and | ||
| uses ODOO.LIST formulas to display sale order line data (product, | ||
| quantity, unit price, etc.). Users can add custom formulas, calculations, | ||
| and charts to build complex pricing logic. | ||
|
|
||
| A **Field Sync** side panel lets users map spreadsheet columns to | ||
| sale order line fields. This column-based approach is more intuitive | ||
| than cell-by-cell mapping and makes it easy to push calculated values | ||
| back to the sale order. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| This module requires: | ||
|
|
||
| - ``spreadsheet_oca`` from the OCA spreadsheet repository | ||
| - ``sale_management`` from Odoo core addons | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| Setting up a quotation calculator | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| 1. Go to **Sales > Configuration > Quotation Templates**. | ||
| 2. Open or create a quotation template. | ||
| 3. Click **Create Calculator** next to the "Quotation Calculator" field. | ||
| 4. A wizard will open; set a name and number of initial rows, then click | ||
| **Create Calculator**. | ||
| 5. The spreadsheet editor opens with a pre-configured list of | ||
| ``sale.order.line`` fields. | ||
| 6. Customize the spreadsheet: add formulas, charts, or extra columns as | ||
| needed. | ||
| 7. Save the spreadsheet. | ||
|
|
||
| Using the calculator on a sale order | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| 1. Create a new quotation and select the template that has a calculator. | ||
| 2. A **Calculator** smart button appears on the sale order form. | ||
| 3. Click it to open the spreadsheet filtered to the current order's | ||
| lines. | ||
| 4. Edit values in the spreadsheet. | ||
| 5. Use **File > Field Sync** to map columns to sale order line fields. | ||
| 6. Save the spreadsheet from the editor. | ||
|
|
||
| Syncing values back to the order | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| After configuring field sync mappings in the spreadsheet, the mapped | ||
| column values can be pushed to the corresponding sale order line fields | ||
| when saving the spreadsheet or from the sale order form. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
| access_spreadsheet_quotation_create,access_spreadsheet_quotation_create,model_spreadsheet_quotation_create,sales_team.group_sale_salesman,1,1,1,1 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.