Skip to content

Commit 699d42a

Browse files
committed
[ADD] product_supplierinfo_update_price: New module
1 parent 134f93e commit 699d42a

File tree

15 files changed

+795
-0
lines changed

15 files changed

+795
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
=================================
2+
Product Supplierinfo Update Price
3+
=================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:88b21b905daef2080395a4e6bd3a7fc03604e2cd7bb7c90f213c5906cd971c1a
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/16.0/product_supplierinfo_update_price
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-16-0/purchase-workflow-16-0-product_supplierinfo_update_price
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=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allows updating the product's vendor price from the purchase
32+
order line.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Usage
40+
=====
41+
42+
To use this module, you need to:
43+
44+
- Go to Purchase > New Purchase
45+
46+
- Set the supplier and add a purchase order line with a product and its
47+
price
48+
49+
- If the price of the product on the purchase order line for that
50+
supplier is different from the price set in the product's vendor list
51+
(on the purchase tab), or if no vendor entry exists, a refresh button
52+
will appear to the right of the unit price. Otherwise, the button will
53+
not be shown.
54+
55+
- If you click the refresh button, the vendor price will be updated or a
56+
new vendor entry will be created, as appropriate.
57+
58+
Bug Tracker
59+
===========
60+
61+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
62+
In case of trouble, please check there if your issue has already been reported.
63+
If you spotted it first, help us to smash it by providing a detailed and welcomed
64+
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20product_supplierinfo_update_price%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
65+
66+
Do not contact contributors directly about support or help with technical issues.
67+
68+
Credits
69+
=======
70+
71+
Authors
72+
-------
73+
74+
* Dixmit
75+
76+
Contributors
77+
------------
78+
79+
- `Dixmit <https://www.dixmit.com>`__:
80+
81+
- Luis Rodríguez <[email protected]>
82+
83+
Maintainers
84+
-----------
85+
86+
This module is maintained by the OCA.
87+
88+
.. image:: https://odoo-community.org/logo.png
89+
:alt: Odoo Community Association
90+
:target: https://odoo-community.org
91+
92+
OCA, or the Odoo Community Association, is a nonprofit organization whose
93+
mission is to support the collaborative development of Odoo features and
94+
promote its widespread use.
95+
96+
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/16.0/product_supplierinfo_update_price>`_ project on GitHub.
97+
98+
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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2025 Dixmit
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Product Supplierinfo Update Price",
6+
"summary": """Updates the product's vendor price with the price
7+
set in a purchase order.""",
8+
"version": "16.0.1.0.0",
9+
"license": "AGPL-3",
10+
"author": "Dixmit,Odoo Community Association (OCA)",
11+
"website": "https://github.com/OCA/purchase-workflow",
12+
"depends": [
13+
"purchase",
14+
"product",
15+
],
16+
"data": [
17+
"views/purchase_views.xml",
18+
],
19+
"demo": [],
20+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import purchase_order_line
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright 2025 Dixmit
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import api, fields, models
5+
6+
7+
class PurchaseOrderLine(models.Model):
8+
_inherit = "purchase.order.line"
9+
10+
can_update_product_supplierinfo = fields.Boolean(
11+
compute="_compute_can_update_product_supplierinfo",
12+
)
13+
14+
def action_update_product_supplierinfo(self):
15+
self.ensure_one()
16+
17+
product_supplierinfo = self.product_id._select_seller(
18+
partner_id=self.partner_id,
19+
quantity=self.product_qty,
20+
date=self.order_id.date_order
21+
and self.order_id.date_order.date()
22+
or fields.Date.context_today(self),
23+
uom_id=self.product_uom,
24+
params=self._get_select_sellers_params(),
25+
)
26+
27+
if product_supplierinfo:
28+
product_supplierinfo.write(
29+
{
30+
"price": self.price_unit,
31+
}
32+
)
33+
else:
34+
self.product_id.seller_ids.create(
35+
{
36+
"partner_id": self.partner_id.id,
37+
"product_tmpl_id": self.product_id.product_tmpl_id.id,
38+
"price": self.price_unit,
39+
}
40+
)
41+
42+
@api.onchange("product_id", "partner_id", "price_unit")
43+
def _compute_can_update_product_supplierinfo(self):
44+
for line in self:
45+
product_supplierinfo = line.product_id._select_seller(
46+
partner_id=line.partner_id,
47+
quantity=line.product_qty,
48+
date=line.order_id.date_order
49+
and line.order_id.date_order.date()
50+
or fields.Date.context_today(self),
51+
uom_id=line.product_uom,
52+
params=line._get_select_sellers_params(),
53+
)
54+
line.can_update_product_supplierinfo = bool(
55+
not product_supplierinfo
56+
or product_supplierinfo.price != line.price_unit
57+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [Dixmit](https://www.dixmit.com):
2+
- Luis Rodríguez \<<[email protected]>\>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module allows updating the product's vendor price from the purchase order line.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
To use this module, you need to:
2+
3+
- Go to Purchase > New Purchase
4+
5+
- Set the supplier and add a purchase order line with a product and its price
6+
7+
- If the price of the product on the purchase order line for that supplier is different from the price set in the product's vendor list (on the purchase tab), or if no vendor entry exists, a refresh button will appear to the right of the unit price. Otherwise, the button will not be shown.
8+
9+
- If you click the refresh button, the vendor price will be updated or a new vendor entry will be created, as appropriate.
Loading

0 commit comments

Comments
 (0)