Skip to content

[16.0][MIG][BACKPORT] sale_commission_pricelist: 17.0 -> 16.0#633

Open
felipemotter wants to merge 44 commits intoOCA:16.0from
Engenere:16.0-mig-sale_commission_pricelist
Open

[16.0][MIG][BACKPORT] sale_commission_pricelist: 17.0 -> 16.0#633
felipemotter wants to merge 44 commits intoOCA:16.0from
Engenere:16.0-mig-sale_commission_pricelist

Conversation

@felipemotter
Copy link
Copy Markdown
Contributor

Migration of sale_commission_pricelist to version 16.0. Instead of porting from 14.0/15.0, I chose to backport from 17.0, as the diff is nearly identical.

carlosdauden and others added 30 commits August 5, 2025 22:53
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: commission-12.0/commission-12.0-sale_commission_pricelist
Translate-URL: https://translation.odoo-community.org/projects/commission-12-0/commission-12-0-sale_commission_pricelist/
Currently translated at 100.0% (3 of 3 strings)

Translation: commission-12.0/commission-12.0-sale_commission_pricelist
Translate-URL: https://translation.odoo-community.org/projects/commission-12-0/commission-12-0-sale_commission_pricelist/it/
Currently translated at 100.0% (3 of 3 strings)

Translation: commission-12.0/commission-12.0-sale_commission_pricelist
Translate-URL: https://translation.odoo-community.org/projects/commission-12-0/commission-12-0-sale_commission_pricelist/zh_CN/
Currently translated at 100.0% (3 of 3 strings)

Translation: commission-12.0/commission-12.0-sale_commission_pricelist
Translate-URL: https://translation.odoo-community.org/projects/commission-12-0/commission-12-0-sale_commission_pricelist/pt/
Currently translated at 100.0% (3 of 3 strings)

Translation: commission-12.0/commission-12.0-sale_commission_pricelist
Translate-URL: https://translation.odoo-community.org/projects/commission-12-0/commission-12-0-sale_commission_pricelist/pt_BR/
Currently translated at 100.0% (3 of 3 strings)

Translation: commission-12.0/commission-12.0-sale_commission_pricelist
Translate-URL: https://translation.odoo-community.org/projects/commission-12-0/commission-12-0-sale_commission_pricelist/pt_BR/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: commission-13.0/commission-13.0-sale_commission_pricelist
Translate-URL: https://translation.odoo-community.org/projects/commission-13-0/commission-13-0-sale_commission_pricelist/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: commission-13.0/commission-13.0-sale_commission_pricelist
Translate-URL: https://translation.odoo-community.org/projects/commission-13-0/commission-13-0-sale_commission_pricelist/
Currently translated at 100.0% (3 of 3 strings)

Translation: commission-13.0/commission-13.0-sale_commission_pricelist
Translate-URL: https://translation.odoo-community.org/projects/commission-13-0/commission-13-0-sale_commission_pricelist/es_AR/
cjallais and others added 14 commits August 5, 2025 22:53
Currently translated at 100.0% (3 of 3 strings)

Translation: commission-14.0/commission-14.0-sale_commission_pricelist
Translate-URL: https://translation.odoo-community.org/projects/commission-14-0/commission-14-0-sale_commission_pricelist/it/
Currently translated at 100.0% (3 of 3 strings)

Translation: commission-14.0/commission-14.0-sale_commission_pricelist
Translate-URL: https://translation.odoo-community.org/projects/commission-14-0/commission-14-0-sale_commission_pricelist/pt_BR/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: commission-14.0/commission-14.0-sale_commission_pricelist
Translate-URL: https://translation.odoo-community.org/projects/commission-14-0/commission-14-0-sale_commission_pricelist/
Currently translated at 100.0% (6 of 6 strings)

Translation: commission-14.0/commission-14.0-sale_commission_pricelist
Translate-URL: https://translation.odoo-community.org/projects/commission-14-0/commission-14-0-sale_commission_pricelist/it/
Currently translated at 100.0% (6 of 6 strings)

Translation: commission-14.0/commission-14.0-sale_commission_pricelist
Translate-URL: https://translation.odoo-community.org/projects/commission-14-0/commission-14-0-sale_commission_pricelist/es/
Copy link
Copy Markdown
Member

@marcelsavegnago marcelsavegnago left a comment

Choose a reason for hiding this comment

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

LGTM

@OCA-git-bot
Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Copy link
Copy Markdown
Member

@hildickethan hildickethan left a comment

Choose a reason for hiding this comment

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

LGTM

@felipemotter
Copy link
Copy Markdown
Contributor Author

Hello maintainers,
Could you please check whether this PR complies with the repository guidelines and let me know if anything needs to be adjusted before it can be merged?

Copy link
Copy Markdown

@marcos-mendez marcos-mendez left a comment

Choose a reason for hiding this comment

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

Automated Review -- Tests Passed

All tests for sale_commission_pricelist passed successfully on Odoo 16.0.
Environment: Minikube + K8s Job + oca-ci/py3.10-odoo16.0


Test Coverage Suggestions

Coverage Gaps

The existing tests appear to cover the core functionality, but there are some potential gaps:

  1. Edge case for _get_commission_from_pricelist: The method returns False early if product_id or pricelist_id is missing, but there's no explicit test for this path.
  2. Commission inheritance logic in SaleOrderLineAgent._compute_commission_id: The method overrides the parent logic and falls back to agent_id.commission_id, but it's not tested whether this fallback works correctly when pricelist commission is missing.
  3. No test for pricelist item without commission: It's unclear if the system handles correctly a pricelist item with no commission set (should fallback to agent default).

Suggested Test Cases

def test_get_commission_from_pricelist_no_product(self):
    """Test that _get_commission_from_pricelist returns False when no product."""
    line = self.env['sale.order.line'].new({'product_id': False})
    self.assertFalse(line._get_commission_from_pricelist())

def test_compute_commission_id_fallback_to_agent(self):
    """Test that commission falls back to agent when pricelist item has no commission."""
    agent = self.env['commission'].create({'name': 'Test Agent', 'fix_qty': 10.0})
    pricelist_item = self.env['product.pricelist.item'].create({
        'pricelist_id': self.env['product.pricelist'].create({'name': 'Test'}).id,
        'product_id': self.env.ref('product.product_product_1').id,
        'commission_id': False,  # No commission set
    })
    line = self.env['sale.order.line'].create({
        'order_id': self.env['sale.order'].create({'partner_id': self.env.ref('base.res_partner_1').id}).id,
        'product_id': self.env.ref('product.product_product_1').id,
        'product_uom_qty': 1.0,
    })
    line.order_id.pricelist_id = pricelist_item.pricelist_id
    # Ensure agent is set on the line
    line.agent_ids = [(0, 0, {'agent_id': agent.id})]
    # This should fallback to agent commission
    self.assertEqual(line.agent_ids.commission_id, agent)

def test_commission_from_pricelist_item(self):
    """Test that commission is correctly retrieved from pricelist item."""
    commission = self.env['commission'].create({'name': 'Test Commission', 'fix_qty': 5.0})
    pricelist_item = self.env['product.pricelist.item'].create({
        'pricelist_id': self.env['product.pricelist'].create({'name': 'Test'}).id,
        'product_id': self.env.ref('product.product_product_1').id,
        'commission_id': commission.id,
    })
    line = self.env['sale.order.line'].create({
        'order_id': self.env['sale.order'].create({'partner_id': self.env.ref('base.res_partner_1').id}).id,
        'product_id': self.env.ref('product.product_product_1').id,
        'product_uom_qty': 1.0,
    })
    line.order_id.pricelist_id = pricelist_item.pricelist_id
    # This should return the pricelist item's commission
    self.assertEqual(line._get_commission_from_pricelist(), commission)

Codecov Risk

The following methods are new and have potential coverage risks:

  1. SaleOrderLine._get_commission_from_pricelist() - Edge cases around missing data
  2. SaleOrderLineAgent._compute_commission_id() - Logic involving fallback behavior
  3. ProductPricelistItem.commission_id - Field addition, but logic is minimal

These methods should be tested to ensure full coverage, especially the fallback logic in _compute_commission_id.


⚠️ PR Aging Alert: CRITICAL

This PR by @felipemotter has been waiting for 221 days — that is over 7 months without being merged or closed.
💤 No activity for 100 days. Has this PR been forgotten?

Every ignored PR is a contributor who might not come back. Review time matters. (OCA Aging Report)


Reciprocal Review Request

Hi everyone! Thanks for your contribution to OCA. I reviewed and approved this PR. If any of you have a moment, I would really appreciate a review on my open PR(s):

My open PRs across OCA:

Reviewing each other's work helps the whole community move forward faster. Thank you!


Automated review by OCA Neural Reviewer + qwen3-coder:30b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.