Skip to content

Commit

Permalink
[14.0][ADD] purchase_update_pricelist: When confirming a purchase ord…
Browse files Browse the repository at this point in the history
…er, update the price unit and discount in "Supplier Pricelist".
  • Loading branch information
alfredoavanzosc authored and anajuaristi committed Nov 27, 2024
1 parent 0549f37 commit 3d3e61d
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 0 deletions.
30 changes: 30 additions & 0 deletions purchase_update_pricelist/README.rst
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>
1 change: 1 addition & 0 deletions purchase_update_pricelist/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions purchase_update_pricelist/__manifest__.py
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,
}
36 changes: 36 additions & 0 deletions purchase_update_pricelist/i18n/en_GB.po
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 ""
36 changes: 36 additions & 0 deletions purchase_update_pricelist/i18n/es.po
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 purchase_update_pricelist/i18n/purchase_update_pricelist.pot
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 ""
1 change: 1 addition & 0 deletions purchase_update_pricelist/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import purchase_order
39 changes: 39 additions & 0 deletions purchase_update_pricelist/models/purchase_order.py
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
6 changes: 6 additions & 0 deletions setup/purchase_update_pricelist/setup.py
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,
)

0 comments on commit 3d3e61d

Please sign in to comment.