Skip to content

Commit

Permalink
[MIG] partner_supplierinfo_smartbutton: Migration to 16.0
Browse files Browse the repository at this point in the history
TT49758
  • Loading branch information
victoralmau committed Jul 1, 2024
1 parent d081d23 commit e871731
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 28 deletions.
10 changes: 5 additions & 5 deletions partner_supplierinfo_smartbutton/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -61,7 +61,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/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 <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20partner_supplierinfo_smartbutton%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20partner_supplierinfo_smartbutton%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Expand Down Expand Up @@ -102,6 +102,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-victoralmau|

This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/14.0/partner_supplierinfo_smartbutton>`_ project on GitHub.
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/16.0/partner_supplierinfo_smartbutton>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion partner_supplierinfo_smartbutton/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
24 changes: 12 additions & 12 deletions partner_supplierinfo_smartbutton/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -369,7 +368,7 @@ <h1 class="title">Access supplied products from the vendor</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:81e7b1583ab5a956c6d36307cfaa71717d2b022905a7bd41a3232c5cdc86ddea
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/purchase-workflow/tree/14.0/partner_supplierinfo_smartbutton"><img alt="OCA/purchase-workflow" src="https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/purchase-workflow-14-0/purchase-workflow-14-0-partner_supplierinfo_smartbutton"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/purchase-workflow/tree/16.0/partner_supplierinfo_smartbutton"><img alt="OCA/purchase-workflow" src="https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/purchase-workflow-16-0/purchase-workflow-16-0-partner_supplierinfo_smartbutton"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This addon adds a smart-button in the vendors with the supplied products.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand Down Expand Up @@ -412,7 +411,7 @@ <h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/purchase-workflow/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/purchase-workflow/issues/new?body=module:%20partner_supplierinfo_smartbutton%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/purchase-workflow/issues/new?body=module:%20partner_supplierinfo_smartbutton%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -442,7 +441,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/victoralmau"><img alt="victoralmau" src="https://github.com/victoralmau.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/purchase-workflow/tree/14.0/partner_supplierinfo_smartbutton">OCA/purchase-workflow</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/purchase-workflow/tree/16.0/partner_supplierinfo_smartbutton">OCA/purchase-workflow</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -16,24 +16,40 @@ 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},
),
],
}
)
cls.product_b = cls.product_model.create(
{
"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},
),
],
}
)
cls.product_a_b = cls.product_model.create(
{
"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},
),
],
}
)
Expand Down

0 comments on commit e871731

Please sign in to comment.