-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[14.0][ADD] purchase_update_pricelist: When confirming a purchase ord…
…er, update the price unit and discount in "Supplier Pricelist".
- Loading branch information
1 parent
0549f37
commit 3d3e61d
Showing
10 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,30 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
========================= | ||
Purchase update pricelist | ||
========================= | ||
|
||
* When confirming a purchase order, update the price unit and discount in | ||
"Supplier Pricelist". | ||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/avanzosc/odoo-addons/issues>`_. In case of trouble, | ||
please check there if your issue has already been reported. If you spotted | ||
it first, help us smash it by providing detailed and welcomed feedback. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Ana Juaristi <anajuaristi@avanzosc.es> | ||
* Alfredo de la Fuente <alfredodelafuente@avanzosc.es> |
This file contains 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 @@ | ||
from . import models |
This file contains 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,14 @@ | ||
# Copyright 2024 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Purchase Update Pricelist", | ||
"version": "14.0.1.0.0", | ||
"category": "Inventory/Purchase", | ||
"license": "AGPL-3", | ||
"author": "AvanzOSC", | ||
"website": "https://github.com/avanzosc/odoo-addons", | ||
"depends": ["purchase", "purchase_discount"], | ||
"excludes": [], | ||
"data": [], | ||
"installable": True, | ||
} |
This file contains 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,36 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * purchase_update_pricelist | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-09-25 11:36+0000\n" | ||
"PO-Revision-Date: 2024-09-25 11:36+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: purchase_update_pricelist | ||
#: model:ir.model.fields,field_description:purchase_update_pricelist.field_purchase_order__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: purchase_update_pricelist | ||
#: model:ir.model.fields,field_description:purchase_update_pricelist.field_purchase_order__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: purchase_update_pricelist | ||
#: model:ir.model.fields,field_description:purchase_update_pricelist.field_purchase_order____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: purchase_update_pricelist | ||
#: model:ir.model,name:purchase_update_pricelist.model_purchase_order | ||
msgid "Purchase Order" | ||
msgstr "" |
This file contains 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,36 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * purchase_update_pricelist | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-09-25 11:32+0000\n" | ||
"PO-Revision-Date: 2024-09-25 11:32+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: purchase_update_pricelist | ||
#: model:ir.model.fields,field_description:purchase_update_pricelist.field_purchase_order__display_name | ||
msgid "Display Name" | ||
msgstr "Nombre mostrado" | ||
|
||
#. module: purchase_update_pricelist | ||
#: model:ir.model.fields,field_description:purchase_update_pricelist.field_purchase_order__id | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: purchase_update_pricelist | ||
#: model:ir.model.fields,field_description:purchase_update_pricelist.field_purchase_order____last_update | ||
msgid "Last Modified on" | ||
msgstr "Última modificación el" | ||
|
||
#. module: purchase_update_pricelist | ||
#: model:ir.model,name:purchase_update_pricelist.model_purchase_order | ||
msgid "Purchase Order" | ||
msgstr "Pedido de compra" |
36 changes: 36 additions & 0 deletions
36
purchase_update_pricelist/i18n/purchase_update_pricelist.pot
This file contains 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,36 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * purchase_update_pricelist | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-09-25 11:32+0000\n" | ||
"PO-Revision-Date: 2024-09-25 11:32+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: purchase_update_pricelist | ||
#: model:ir.model.fields,field_description:purchase_update_pricelist.field_purchase_order__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: purchase_update_pricelist | ||
#: model:ir.model.fields,field_description:purchase_update_pricelist.field_purchase_order__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: purchase_update_pricelist | ||
#: model:ir.model.fields,field_description:purchase_update_pricelist.field_purchase_order____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: purchase_update_pricelist | ||
#: model:ir.model,name:purchase_update_pricelist.model_purchase_order | ||
msgid "Purchase Order" | ||
msgstr "" |
This file contains 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 @@ | ||
from . import purchase_order |
This file contains 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,39 @@ | ||
# Copyright 2024 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import models | ||
|
||
|
||
class PurchaseOrder(models.Model): | ||
_inherit = "purchase.order" | ||
|
||
def _add_supplier_to_product(self): | ||
result = super(PurchaseOrder, self)._add_supplier_to_product() | ||
self._update_supplier_info_to_product() | ||
return result | ||
|
||
def _update_supplier_info_to_product(self): | ||
for line in self.order_line: | ||
partner = ( | ||
self.partner_id | ||
if not self.partner_id.parent_id | ||
else self.partner_id.parent_id | ||
) | ||
seller = self._find_seller_to_update_suppliernfo_to_product(line, partner) | ||
if seller: | ||
vals = self._catch_values_to_update_seller_in_product(line, seller) | ||
seller.write(vals) | ||
|
||
def _catch_values_to_update_seller_in_product(self, line, seller): | ||
vals = {} | ||
if seller.price != line.price_unit: | ||
vals["price"] = line.price_unit | ||
if seller.discount != line.discount: | ||
vals["discount"] = line.discount | ||
return vals | ||
|
||
def _find_seller_to_update_suppliernfo_to_product(self, line, partner): | ||
seller = line.product_id.seller_ids.filtered( | ||
lambda x: x.name == partner | ||
and (x.price != line.price_unit or x.discount != line.discount) | ||
) | ||
return seller |
1 change: 1 addition & 0 deletions
1
setup/purchase_update_pricelist/odoo/addons/purchase_update_pricelist
This file contains 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 @@ | ||
../../../../purchase_update_pricelist |
This file contains 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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |