Skip to content
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

[FIX] product_margin_classification: compute correctly fields in multi company context. #225

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions product_margin_classification/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ Known issues / Roadmap
due to the poor design of Odoo product module.
This issue can be maybe fixed in new version of Odoo.

* This module will not work for products that available on many
Copy link
Member

@rvalyi rvalyi Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/that available/that are available/
s/on many/in several/

companies, because this module introduces stored fields, that can
not be company dependant, and the fields depends on ``standard_price``
rvalyi marked this conversation as resolved.
Show resolved Hide resolved
that is company dependant.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/dependant/dependent/


Bug Tracker
===========

Expand Down
3 changes: 3 additions & 0 deletions product_margin_classification/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class Productproduct(models.Model):
)
def _compute_theoretical_multi(self):
for product in self:
# Handle special case where self.env.company != product.company_id
# we switch in a new context to avoid to have a bad standard price
product = product.with_company(product.company_id)
(
product.margin_state,
product.theoretical_price,
Expand Down
5 changes: 5 additions & 0 deletions product_margin_classification/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
* This module will not work for variants that have a not null ``price_extra`` value,
due to the poor design of Odoo product module.
This issue can be maybe fixed in new version of Odoo.

* This module will not work for products that available on many
companies, because this module introduces stored fields, that can
not be company dependant, and the fields depends on ``standard_price``
that is company dependant.
15 changes: 11 additions & 4 deletions product_margin_classification/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -429,6 +430,10 @@ <h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<li>This module will not work for variants that have a not null <tt class="docutils literal">price_extra</tt> value,
due to the poor design of Odoo product module.
This issue can be maybe fixed in new version of Odoo.</li>
<li>This module will not work for products that available on many
companies, because this module introduces stored fields, that can
not be company dependant, and the fields depends on <tt class="docutils literal">standard_price</tt>
that is company dependant.</li>
</ul>
</div>
<div class="section" id="bug-tracker">
Expand Down Expand Up @@ -457,7 +462,9 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
Expand Down
Loading