Skip to content

Commit 9a75aad

Browse files
committed
[14.0][ADD] sale_pricelist_packaging
1 parent 1256fff commit 9a75aad

File tree

14 files changed

+737
-0
lines changed

14 files changed

+737
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
========================
2+
Sale Pricelist Packaging
3+
========================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:14e7fa40de1ec46148b3ccae7be7a38dd3d6d213766586d618e604da92091087
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
20+
:target: https://github.com/OCA/purchase-workflow/tree/14.0/sale_pricelist_packaging
21+
:alt: OCA/purchase-workflow
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/purchase-workflow-14-0/purchase-workflow-14-0-sale_pricelist_packaging
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=14.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module adds packaging to the product.pricelist.item and allows you to sell the same product with different packaging and at different prices.
32+
33+
**Table of contents**
34+
35+
.. contents::
36+
:local:
37+
38+
Bug Tracker
39+
===========
40+
41+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
42+
In case of trouble, please check there if your issue has already been reported.
43+
If you spotted it first, help us to smash it by providing a detailed and welcomed
44+
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20sale_pricelist_packaging%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
45+
46+
Do not contact contributors directly about support or help with technical issues.
47+
48+
Credits
49+
=======
50+
51+
Authors
52+
~~~~~~~
53+
54+
* Akretion
55+
56+
Contributors
57+
~~~~~~~~~~~~
58+
59+
* Mathieu Delva <[email protected]>
60+
61+
Maintainers
62+
~~~~~~~~~~~
63+
64+
This module is maintained by the OCA.
65+
66+
.. image:: https://odoo-community.org/logo.png
67+
:alt: Odoo Community Association
68+
:target: https://odoo-community.org
69+
70+
OCA, or the Odoo Community Association, is a nonprofit organization whose
71+
mission is to support the collaborative development of Odoo features and
72+
promote its widespread use.
73+
74+
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/14.0/sale_pricelist_packaging>`_ project on GitHub.
75+
76+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2025 Akretion (https://www.akretion.com).
2+
# @author Mathieu DELVA <[email protected]>
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
5+
{
6+
"name": "Sale Pricelist Packaging",
7+
"summary": "Sale Pricelist Packaging",
8+
"version": "14.0.1.0.0",
9+
"category": "sale",
10+
"website": "https://github.com/OCA/purchase-workflow",
11+
"author": " Akretion, Odoo Community Association (OCA)",
12+
"license": "AGPL-3",
13+
"depends": [
14+
"sale",
15+
"stock",
16+
],
17+
"data": ["views/product_pricelist.xml"],
18+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import product_pricelist
2+
from . import sale_order
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2025 Akretion (https://www.akretion.com).
2+
# @author Mathieu DELVA <[email protected]>
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
from odoo import fields, models
5+
6+
7+
class ProductPricelistItem(models.Model):
8+
_inherit = "product.pricelist.item"
9+
10+
packaging_id = fields.Many2one("product.packaging")
11+
12+
def _is_applicable_for(self, product, qty_in_product_uom):
13+
ctx = self.env.context
14+
packaging = False
15+
if "packaging" in ctx:
16+
packaging = ctx["packaging"]
17+
if packaging == self.packaging_id:
18+
return super()._is_applicable_for(product, qty_in_product_uom)
19+
else:
20+
return False
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright 2025 Akretion (https://www.akretion.com).
2+
# @author Mathieu DELVA <[email protected]>
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
from odoo import api, models
5+
6+
7+
class SaleOrderLine(models.Model):
8+
_inherit = "sale.order.line"
9+
10+
def _get_display_price(self, product):
11+
product = product or self.product_id
12+
product = product.with_context(packaging=self.product_packaging)
13+
return super()._get_display_price(product)
14+
15+
@api.onchange("product_packaging")
16+
def _onchange_product_packaging(self):
17+
if not self.product_uom or not self.product_id:
18+
self.price_unit = 0.0
19+
elif self.order_id.pricelist_id and self.order_id.partner_id:
20+
product = self.product_id.with_context(
21+
lang=self.order_id.partner_id.lang,
22+
partner=self.order_id.partner_id,
23+
quantity=self.product_uom_qty,
24+
date=self.order_id.date_order,
25+
pricelist=self.order_id.pricelist_id.id,
26+
uom=self.product_uom.id,
27+
fiscal_position=self.env.context.get("fiscal_position"),
28+
)
29+
self.price_unit = product._get_tax_included_unit_price(
30+
self.company_id,
31+
self.order_id.currency_id,
32+
self.order_id.date_order,
33+
"sale",
34+
fiscal_position=self.order_id.fiscal_position_id,
35+
product_price_unit=self._get_display_price(product),
36+
product_currency=self.order_id.currency_id,
37+
)
38+
return super()._onchange_product_packaging()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Mathieu Delva <[email protected]>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module adds packaging to the product.pricelist.item and allows you to sell the same product with different packaging and at different prices.

0 commit comments

Comments
 (0)