-
-
Notifications
You must be signed in to change notification settings - Fork 803
[18.0][IMP] product_secondary_unit: add configuration for report presentation #2211
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
AungKoKoLin1997
wants to merge
1
commit into
OCA:18.0
Choose a base branch
from
qrtl:18.0-imp-report_configuration_product_secondary_unit
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.
+378
−33
Open
Changes from all commits
Commits
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
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
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,51 @@ | ||
| # Copyright 2026 Quartile (https://www.quartile.co) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo import fields, models | ||
|
|
||
| PRICE_DISPLAY_SELECTION = [ | ||
| ("primary", "Primary Unit Price Only"), | ||
| ("secondary", "Prioritize Secondary Unit Price"), | ||
| ("both", "Both Primary and Secondary Unit Prices"), | ||
| ] | ||
|
|
||
|
|
||
| class ResCompany(models.Model): | ||
| _inherit = "res.company" | ||
|
|
||
| secondary_uom_price_display_sale = fields.Selection( | ||
| selection=PRICE_DISPLAY_SELECTION, | ||
| string="Secondary Unit Price Display (Sales)", | ||
| default="primary", | ||
| required=True, | ||
| ) | ||
| secondary_uom_price_display_purchase = fields.Selection( | ||
| selection=PRICE_DISPLAY_SELECTION, | ||
| string="Secondary Unit Price Display (Purchase)", | ||
| default="primary", | ||
| required=True, | ||
| ) | ||
| # Added for supporting the existing report presentation. We can drop this together | ||
| # with the second qty column in reports if the community agrees with it. | ||
| hide_secondary_uom_column_sale = fields.Boolean( | ||
| string="Hide Secondary UoM Column (Sales)", | ||
| default=False, | ||
| ) | ||
| hide_secondary_uom_column_purchase = fields.Boolean( | ||
| string="Hide Secondary UoM Column (Purchase)", | ||
| default=False, | ||
| ) | ||
|
|
||
| def hide_secondary_uom_column(self, record): | ||
| """Return whether to hide the 'Second Qty' column for this document type.""" | ||
| if record._name == "sale.order" or ( | ||
| record._name == "account.move" | ||
| and record.is_sale_document(include_receipts=True) | ||
| ): | ||
| return self.hide_secondary_uom_column_sale | ||
| if record._name == "purchase.order" or ( | ||
| record._name == "account.move" | ||
| and record.is_purchase_document(include_receipts=True) | ||
| ): | ||
| return self.hide_secondary_uom_column_purchase | ||
| return True | ||
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,25 @@ | ||
| # Copyright 2026 Quartile (https://www.quartile.co) | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class ResConfigSettings(models.TransientModel): | ||
| _inherit = "res.config.settings" | ||
|
|
||
| secondary_uom_price_display_sale = fields.Selection( | ||
| related="company_id.secondary_uom_price_display_sale", | ||
| readonly=False, | ||
| ) | ||
| secondary_uom_price_display_purchase = fields.Selection( | ||
| related="company_id.secondary_uom_price_display_purchase", | ||
| readonly=False, | ||
| ) | ||
| hide_secondary_uom_column_sale = fields.Boolean( | ||
| related="company_id.hide_secondary_uom_column_sale", | ||
| readonly=False, | ||
| ) | ||
| hide_secondary_uom_column_purchase = fields.Boolean( | ||
| related="company_id.hide_secondary_uom_column_purchase", | ||
| readonly=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,34 @@ | ||
| To configure this module, go to **Settings** and locate the **Units of Measure** | ||
| section. | ||
|
|
||
| ## Secondary Unit Price Display | ||
|
|
||
| Configure how unit prices and quantities are shown in reports when secondary units are | ||
| used. | ||
|
|
||
| - **Sales**: Select the display policy for sales order and customer invoice reports and | ||
| portal views. | ||
| - **Purchase**: Select the display policy for purchase order and vendor bill reports and | ||
| portal views. | ||
|
|
||
| Available options: | ||
|
|
||
| - **Primary Unit Price Only**: Show only the primary unit price. | ||
| - **Prioritize Secondary Unit Price**: Show the secondary unit price when available, | ||
| otherwise fall back to the primary unit price. | ||
| - **Both Primary and Secondary Unit Prices**: Show both primary and secondary unit | ||
| prices. | ||
|
|
||
| ## Hide Secondary Qty Column | ||
|
|
||
| Hide the separate **Second Qty** column in reports. | ||
|
|
||
| - When enabled, the **Second Qty** column is hidden in reports. The secondary quantity | ||
| can still be shown in the main **Qty** column depending on the selected price display | ||
| policy above. | ||
| - Apply the setting per document type: | ||
| - **Sales** | ||
| - **Purchase** | ||
|
|
||
| These settings are intended to be used by dependency modules (for example, | ||
| `purchase_order_secondary_unit` and `account_move_secondary_unit`). |
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
11 changes: 11 additions & 0 deletions
11
product_secondary_unit/security/product_secondary_unit_groups.xml
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,11 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <odoo> | ||
| <record id="group_sale_secondary_unit" model="res.groups"> | ||
| <field name="name">Sale Secondary Unit</field> | ||
| <field name="category_id" ref="base.module_category_hidden" /> | ||
| </record> | ||
| <record id="group_purchase_secondary_unit" model="res.groups"> | ||
| <field name="name">Purchase Secondary Unit</field> | ||
| <field name="category_id" ref="base.module_category_hidden" /> | ||
| </record> | ||
| </odoo> |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This configurability level seems a bit insane. Are you going to display UoM price on sale, but not on purchase, but show the UoM? Can't this be fit with a single security group "Show seconday unit prices"?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For showing the UoM column option, it is intended only to preserve the existing Sales/Purchase report behavior of
sale_order_secondary_unitandpurchase_order_secondary_unitwhenPrimary Unit Price Onlyis selected. For the other price display modes, the secondary UoM is already shown in thequantityandpricecolumns, so showing an additional UoM column would be redundant.I don't think Sales and Purchase should always share the same display style for the secondary unit price and the secondary unit column. Therefore, I prefer separate settings for Sales and Purchase documents, with separate security groups to control each document type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the expected report when

Primary Unit Price Onlyis selected without hiding the UoM column.This is the expected report when

Prioritize Secondary Unit Priceis selected.This is the expected report when

Both Primary and Secondary Unit Pricesis selected.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But as said, this is too many configurations, while it's not a usual problem to show both. This only increases the maintenance burden to the main module being a residual feature that most people won't use, being enough with the default option. I think this has to be simplified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pedrobaeza To me it makes sense to be able to configure sales and purchasing separately as they have different needs. But we can do the secondary UoM price display thing in a separate module if it's too much to be covered in the main module, which will mean four new additional modules (i.e., product_secondary_unit_price, purchase_order_secondary_unit_price, sale_order_secondary_unit_price and account_move_secondary_unit_price).
What we still want to do in this module, though, is to be able to hide the secondary qty column in reports. For this, we don't need to have separate config for sales and purchasing (as we will most likely disable this for both anyway).
Does this sound like a good approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sergio-teruel is the main creator of this module, so I let him to decide at last if he considers OK to have all the configuration tweaks in the main module.