From e871731885871fe292f020c1ae137900dcac9782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Mon, 1 Jul 2024 17:16:10 +0200 Subject: [PATCH] [MIG] partner_supplierinfo_smartbutton: Migration to 16.0 TT49758 --- partner_supplierinfo_smartbutton/README.rst | 10 +++---- .../__manifest__.py | 2 +- .../models/res_partner.py | 24 ++++++++-------- .../static/description/index.html | 7 ++--- .../test_partner_supplierinfo_smartbutton.py | 28 +++++++++++++++---- 5 files changed, 43 insertions(+), 28 deletions(-) diff --git a/partner_supplierinfo_smartbutton/README.rst b/partner_supplierinfo_smartbutton/README.rst index 471050f79e1..3cfe4f76917 100644 --- a/partner_supplierinfo_smartbutton/README.rst +++ b/partner_supplierinfo_smartbutton/README.rst @@ -17,13 +17,13 @@ Access supplied products from the vendor :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github - :target: https://github.com/OCA/purchase-workflow/tree/14.0/partner_supplierinfo_smartbutton + :target: https://github.com/OCA/purchase-workflow/tree/16.0/partner_supplierinfo_smartbutton :alt: OCA/purchase-workflow .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/purchase-workflow-14-0/purchase-workflow-14-0-partner_supplierinfo_smartbutton + :target: https://translation.odoo-community.org/projects/purchase-workflow-16-0/purchase-workflow-16-0-partner_supplierinfo_smartbutton :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=14.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -61,7 +61,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -102,6 +102,6 @@ Current `maintainer `__: |maintainer-victoralmau| -This module is part of the `OCA/purchase-workflow `_ project on GitHub. +This module is part of the `OCA/purchase-workflow `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/partner_supplierinfo_smartbutton/__manifest__.py b/partner_supplierinfo_smartbutton/__manifest__.py index 85f8513f91a..c3923df4c18 100644 --- a/partner_supplierinfo_smartbutton/__manifest__.py +++ b/partner_supplierinfo_smartbutton/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Access supplied products from the vendor", - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "category": "Purchase Management", "website": "https://github.com/OCA/purchase-workflow", "author": "Tecnativa, Odoo Community Association (OCA)", diff --git a/partner_supplierinfo_smartbutton/models/res_partner.py b/partner_supplierinfo_smartbutton/models/res_partner.py index f7961b48963..e648811d1a9 100644 --- a/partner_supplierinfo_smartbutton/models/res_partner.py +++ b/partner_supplierinfo_smartbutton/models/res_partner.py @@ -7,28 +7,28 @@ class ResPartner(models.Model): _inherit = "res.partner" - product_supplied_count = fields.Integer( - compute="_compute_product_supplied_count", string="Product Supplied Count" - ) + product_supplied_count = fields.Integer(compute="_compute_product_supplied_count") def _compute_product_supplied_count(self): - supplierinfo_data = self.env["product.supplierinfo"].read_group( - [("name", "in", self.ids)], ["name"], ["name"] + data = self.env["product.supplierinfo"].read_group( + [("partner_id", "in", self.ids)], ["partner_id"], ["partner_id"] ) - mapping = {data["name"][0]: data["name_count"] for data in supplierinfo_data} + mapping = {d["partner_id"][0]: d["partner_id_count"] for d in data} for item in self: item.product_supplied_count = mapping.get(item.id, 0) def action_see_products_by_seller(self): - domain = [("name", "=", self.id)] - res = self.env.ref("product.product_supplierinfo_type_action").sudo().read()[0] + domain = [("partner_id", "=", self.id)] + action = self.env["ir.actions.act_window"]._for_xml_id( + "product.product_supplierinfo_type_action" + ) ctx = dict(self.env.context) ctx.update( { - "default_name": self.id, - "search_default_name": self.id, + "default_partner_id": self.id, + "search_default_partner_id": self.id, "visible_product_tmpl_id": False, } ) - res.update({"domain": domain, "context": ctx}) - return res + action.update({"domain": domain, "context": ctx}) + return action diff --git a/partner_supplierinfo_smartbutton/static/description/index.html b/partner_supplierinfo_smartbutton/static/description/index.html index ce3b8c54d6f..929e64ca79b 100644 --- a/partner_supplierinfo_smartbutton/static/description/index.html +++ b/partner_supplierinfo_smartbutton/static/description/index.html @@ -1,4 +1,3 @@ - @@ -369,7 +368,7 @@

Access supplied products from the vendor

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:81e7b1583ab5a956c6d36307cfaa71717d2b022905a7bd41a3232c5cdc86ddea !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

This addon adds a smart-button in the vendors with the supplied products.

Table of contents

@@ -412,7 +411,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -442,7 +441,7 @@

Maintainers

promote its widespread use.

Current maintainer:

victoralmau

-

This module is part of the OCA/purchase-workflow project on GitHub.

+

This module is part of the OCA/purchase-workflow project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/partner_supplierinfo_smartbutton/tests/test_partner_supplierinfo_smartbutton.py b/partner_supplierinfo_smartbutton/tests/test_partner_supplierinfo_smartbutton.py index 6b69f5ba647..12850f93613 100644 --- a/partner_supplierinfo_smartbutton/tests/test_partner_supplierinfo_smartbutton.py +++ b/partner_supplierinfo_smartbutton/tests/test_partner_supplierinfo_smartbutton.py @@ -1,9 +1,9 @@ # Copyright 2022 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo.tests import common +from odoo.addons.base.tests.common import BaseCommon -class TestPartnerSupplierinfoSmartbutton(common.SavepointCase): +class TestPartnerSupplierinfoSmartbutton(BaseCommon): @classmethod def setUpClass(cls): super().setUpClass() @@ -16,7 +16,11 @@ def setUpClass(cls): { "name": "Test product A", "seller_ids": [ - (0, False, {"name": cls.partner_a.id, "min_qty": 1, "price": 10}), + ( + 0, + False, + {"partner_id": cls.partner_a.id, "min_qty": 1, "price": 10}, + ), ], } ) @@ -24,7 +28,11 @@ def setUpClass(cls): { "name": "Test product B", "seller_ids": [ - (0, False, {"name": cls.partner_b.id, "min_qty": 1, "price": 10}), + ( + 0, + False, + {"partner_id": cls.partner_b.id, "min_qty": 1, "price": 10}, + ), ], } ) @@ -32,8 +40,16 @@ def setUpClass(cls): { "name": "Test product A+B", "seller_ids": [ - (0, False, {"name": cls.partner_a.id, "min_qty": 1, "price": 10}), - (0, False, {"name": cls.partner_b.id, "min_qty": 1, "price": 20}), + ( + 0, + False, + {"partner_id": cls.partner_a.id, "min_qty": 1, "price": 10}, + ), + ( + 0, + False, + {"partner_id": cls.partner_b.id, "min_qty": 1, "price": 20}, + ), ], } )