Skip to content

Commit 96ea1f9

Browse files
committed
[MIG] purchase_allowed_product: Migration to 18.0
1 parent 95abc87 commit 96ea1f9

File tree

9 files changed

+64
-53
lines changed

9 files changed

+64
-53
lines changed

purchase_allowed_product/README.rst

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
15
====================================
26
Purchase and Invoice Allowed Product
37
====================================
@@ -7,23 +11,23 @@ Purchase and Invoice Allowed Product
711
!! This file is generated by oca-gen-addon-readme !!
812
!! changes will be overwritten. !!
913
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:376569ec84ca307bb83baf306b91200c633f7ee20fd6f9feb448155fb174beef
14+
!! source digest: sha256:eb1b9dbaa74e94be393c30f67b80add2d636d716a513727c65216e10fe1b6cc1
1115
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1216
1317
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1418
:target: https://odoo-community.org/page/development-status
1519
:alt: Beta
16-
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
1721
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1822
:alt: License: AGPL-3
1923
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
20-
:target: https://github.com/OCA/purchase-workflow/tree/17.0/purchase_allowed_product
24+
:target: https://github.com/OCA/purchase-workflow/tree/18.0/purchase_allowed_product
2125
:alt: OCA/purchase-workflow
2226
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/purchase-workflow-17-0/purchase-workflow-17-0-purchase_allowed_product
27+
:target: https://translation.odoo-community.org/projects/purchase-workflow-18-0/purchase-workflow-18-0-purchase_allowed_product
2428
:alt: Translate me on Weblate
2529
.. |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=17.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=18.0
2731
:alt: Try me on Runboat
2832

2933
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -48,7 +52,7 @@ Bug Tracker
4852
Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
4953
In case of trouble, please check there if your issue has already been reported.
5054
If you spotted it first, help us to smash it by providing a detailed and welcomed
51-
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_allowed_product%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
55+
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_allowed_product%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
5256

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

@@ -76,6 +80,7 @@ Contributors
7680
- Darius Žižys
7781

7882
- Eduardo de Miguel (`Moduon <https://www.moduon.team/>`__)
83+
- Alejandro Parrales <alejandro17parrales@gmail.com>
7984

8085
Maintainers
8186
-----------
@@ -90,6 +95,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
9095
mission is to support the collaborative development of Odoo features and
9196
promote its widespread use.
9297

93-
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/17.0/purchase_allowed_product>`_ project on GitHub.
98+
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/18.0/purchase_allowed_product>`_ project on GitHub.
9499

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

purchase_allowed_product/__manifest__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
"name": "Purchase and Invoice Allowed Product",
77
"summary": "This module allows to select only products that can be "
88
"supplied by the vendor",
9-
"version": "17.0.1.0.0",
9+
"version": "18.0.1.0.0",
1010
"category": "Accounting & Finance",
1111
"website": "https://github.com/OCA/purchase-workflow",
1212
"author": "Akretion, Odoo Community Association (OCA)",
1313
"license": "AGPL-3",
14-
"depends": ["purchase", "base_view_inheritance_extension"],
14+
"depends": [
15+
"purchase",
16+
"base_view_inheritance_extension",
17+
],
1518
"data": [
1619
"views/res_partner_views.xml",
1720
"views/account_move_views.xml",

purchase_allowed_product/i18n/purchase_allowed_product.pot

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
msgid ""
66
msgstr ""
7-
"Project-Id-Version: Odoo Server 17.0\n"
7+
"Project-Id-Version: Odoo Server 18.0\n"
88
"Report-Msgid-Bugs-To: \n"
99
"Last-Translator: \n"
1010
"Language-Team: \n"
@@ -30,7 +30,6 @@ msgstr ""
3030
#. module: purchase_allowed_product
3131
#: model:ir.model.fields,help:purchase_allowed_product.field_account_bank_statement_line__use_only_supplied_product
3232
#: model:ir.model.fields,help:purchase_allowed_product.field_account_move__use_only_supplied_product
33-
#: model:ir.model.fields,help:purchase_allowed_product.field_account_payment__use_only_supplied_product
3433
#: model:ir.model.fields,help:purchase_allowed_product.field_purchase_order__use_only_supplied_product
3534
#: model:ir.model.fields,help:purchase_allowed_product.field_supplied_product_mixin__use_only_supplied_product
3635
msgid "If checked, only the products provided by this supplier will be shown."
@@ -70,7 +69,6 @@ msgstr ""
7069
#. module: purchase_allowed_product
7170
#: model:ir.model.fields,field_description:purchase_allowed_product.field_account_bank_statement_line__use_only_supplied_product
7271
#: model:ir.model.fields,field_description:purchase_allowed_product.field_account_move__use_only_supplied_product
73-
#: model:ir.model.fields,field_description:purchase_allowed_product.field_account_payment__use_only_supplied_product
7472
#: model:ir.model.fields,field_description:purchase_allowed_product.field_purchase_order__use_only_supplied_product
7573
#: model:ir.model.fields,field_description:purchase_allowed_product.field_supplied_product_mixin__use_only_supplied_product
7674
msgid "Use only allowed products"

purchase_allowed_product/models/product.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def _search(
1616
offset=0,
1717
limit=None,
1818
order=None,
19-
access_rights_uid=None,
2019
):
2120
if self.env.context.get("use_only_supplied_product"):
2221
restrict_supplier_id = self.env.context.get("restrict_supplier_id")
@@ -38,5 +37,4 @@ def _search(
3837
offset=offset,
3938
limit=limit,
4039
order=order,
41-
access_rights_uid=access_rights_uid,
4240
)

purchase_allowed_product/readme/CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
- [Via laurea](https://www.vialaurea.com):
88
- Darius Žižys
99
- Eduardo de Miguel ([Moduon](https://www.moduon.team/))
10+
- Alejandro Parrales \<<alejandro17parrales@gmail.com>\>

purchase_allowed_product/static/description/index.html

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>Purchase and Invoice Allowed Product</title>
6+
<title>README.rst</title>
77
<style type="text/css">
88

99
/*
@@ -360,16 +360,21 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document" id="purchase-and-invoice-allowed-product">
364-
<h1 class="title">Purchase and Invoice Allowed Product</h1>
363+
<div class="document">
365364

365+
366+
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367+
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368+
</a>
369+
<div class="section" id="purchase-and-invoice-allowed-product">
370+
<h1>Purchase and Invoice Allowed Product</h1>
366371
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367372
!! This file is generated by oca-gen-addon-readme !!
368373
!! changes will be overwritten. !!
369374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:376569ec84ca307bb83baf306b91200c633f7ee20fd6f9feb448155fb174beef
375+
!! source digest: sha256:eb1b9dbaa74e94be393c30f67b80add2d636d716a513727c65216e10fe1b6cc1
371376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<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/17.0/purchase_allowed_product"><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-17-0/purchase-workflow-17-0-purchase_allowed_product"><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=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/purchase-workflow/tree/18.0/purchase_allowed_product"><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-18-0/purchase-workflow-18-0-purchase_allowed_product"><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=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373378
<p>This module adds a restriction in purchase and supplier invoices that
374379
has the mark “Order and invoice only supplied products” checked for
375380
allowing to select only products that can be supplied by the defined
@@ -390,23 +395,23 @@ <h1 class="title">Purchase and Invoice Allowed Product</h1>
390395
</ul>
391396
</div>
392397
<div class="section" id="bug-tracker">
393-
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
398+
<h2><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h2>
394399
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/purchase-workflow/issues">GitHub Issues</a>.
395400
In case of trouble, please check there if your issue has already been reported.
396401
If you spotted it first, help us to smash it by providing a detailed and welcomed
397-
<a class="reference external" href="https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_allowed_product%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
402+
<a class="reference external" href="https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_allowed_product%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
398403
<p>Do not contact contributors directly about support or help with technical issues.</p>
399404
</div>
400405
<div class="section" id="credits">
401-
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
406+
<h2><a class="toc-backref" href="#toc-entry-2">Credits</a></h2>
402407
<div class="section" id="authors">
403-
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
408+
<h3><a class="toc-backref" href="#toc-entry-3">Authors</a></h3>
404409
<ul class="simple">
405410
<li>Akretion</li>
406411
</ul>
407412
</div>
408413
<div class="section" id="contributors">
409-
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
414+
<h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
410415
<ul class="simple">
411416
<li>Chafique Delli &lt;<a class="reference external" href="mailto:chafique.delli&#64;akretion.com">chafique.delli&#64;akretion.com</a>&gt;</li>
412417
<li>Mourad EL HADJ MIMOUNE &lt;<a class="reference external" href="mailto:mourad.elhadj.mimoune&#64;akretion.com">mourad.elhadj.mimoune&#64;akretion.com</a>&gt;</li>
@@ -421,21 +426,23 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
421426
</ul>
422427
</li>
423428
<li>Eduardo de Miguel (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
429+
<li>Alejandro Parrales &lt;<a class="reference external" href="mailto:alejandro17parrales&#64;gmail.com">alejandro17parrales&#64;gmail.com</a>&gt;</li>
424430
</ul>
425431
</div>
426432
<div class="section" id="maintainers">
427-
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
433+
<h3><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h3>
428434
<p>This module is maintained by the OCA.</p>
429435
<a class="reference external image-reference" href="https://odoo-community.org">
430436
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
431437
</a>
432438
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
433439
mission is to support the collaborative development of Odoo features and
434440
promote its widespread use.</p>
435-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/purchase-workflow/tree/17.0/purchase_allowed_product">OCA/purchase-workflow</a> project on GitHub.</p>
441+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/purchase-workflow/tree/18.0/purchase_allowed_product">OCA/purchase-workflow</a> project on GitHub.</p>
436442
<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>
437443
</div>
438444
</div>
439445
</div>
446+
</div>
440447
</body>
441448
</html>

purchase_allowed_product/tests/test_purchase_allowed_product.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,43 @@
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
44

55

6-
from odoo.tests.common import Form, TransactionCase
6+
from odoo.tests import Form
77

8+
from odoo.addons.base.tests.common import BaseCommon
89

9-
class TestPurchaseAllowedProduct(TransactionCase):
10-
def setUp(self):
11-
super().setUp()
12-
self.supplierinfo_model = self.env["product.supplierinfo"]
13-
self.product_model = self.env["product.product"]
14-
self.partner_4 = self.env.ref("base.res_partner_4")
15-
self.supplierinfo = self.supplierinfo_model.search(
16-
[("partner_id", "=", self.partner_4.id)]
10+
11+
class TestPurchaseAllowedProduct(BaseCommon):
12+
@classmethod
13+
def setUpClass(cls):
14+
super().setUpClass()
15+
cls.supplierinfo_model = cls.env["product.supplierinfo"]
16+
cls.product_model = cls.env["product.product"]
17+
cls.partner = cls.env["res.partner"].create({"name": "Test supplier"})
18+
cls.supplierinfo = cls.supplierinfo_model.search(
19+
[("partner_id", "=", cls.partner.id)]
1720
)
18-
self.partner_4_supplied_products = self.product_model.search(
21+
cls.partner_supplied_products = cls.product_model.search(
1922
[
2023
(
2124
"product_tmpl_id",
2225
"in",
23-
[x.product_tmpl_id.id for x in self.supplierinfo],
26+
[x.product_tmpl_id.id for x in cls.supplierinfo],
2427
)
2528
]
2629
)
2730

2831
def test_purchase_onchange(self):
2932
"""A user creates a purchase from the form."""
30-
self.partner_4.use_only_supplied_product = True
33+
self.partner.use_only_supplied_product = True
3134
with Form(
3235
self.env["purchase.order"], view="purchase.purchase_order_form"
3336
) as purchase_form:
34-
purchase_form.partner_id = self.partner_4
37+
purchase_form.partner_id = self.partner
3538

3639
# Ensure the use_only_supplied_product is set
3740
self.assertEqual(
3841
purchase_form.use_only_supplied_product,
39-
self.partner_4.use_only_supplied_product,
42+
self.partner.use_only_supplied_product,
4043
)
4144

4245
self.assertEqual(purchase_form.use_only_supplied_product, True)
@@ -45,23 +48,21 @@ def test_purchase_onchange(self):
4548
"use_only_supplied_product": purchase_form.use_only_supplied_product,
4649
}
4750
supplied_product = self.product_model.with_context(**context)._search([])
48-
self.assertEqual(
49-
set(supplied_product), set(self.partner_4_supplied_products.ids)
50-
)
51+
self.assertEqual(set(supplied_product), set(self.partner_supplied_products.ids))
5152

5253
def test_invoice_onchange(self):
5354
"""A user creates a invoice from the form."""
54-
self.partner_4.use_only_supplied_product = True
55+
self.partner.use_only_supplied_product = True
5556
with Form(
5657
self.env["account.move"].with_context(default_move_type="out_invoice"),
5758
view="account.view_move_form",
5859
) as invoice_form:
59-
invoice_form.partner_id = self.partner_4
60+
invoice_form.partner_id = self.partner
6061

6162
# Ensure the use_only_supplied_product is set
6263
self.assertEqual(
6364
invoice_form.use_only_supplied_product,
64-
self.partner_4.use_only_supplied_product,
65+
self.partner.use_only_supplied_product,
6566
)
6667

6768
self.assertEqual(invoice_form.use_only_supplied_product, True)
@@ -70,6 +71,4 @@ def test_invoice_onchange(self):
7071
"use_only_supplied_product": invoice_form.use_only_supplied_product,
7172
}
7273
supplied_product = self.product_model.with_context(**context)._search([])
73-
self.assertEqual(
74-
set(supplied_product), set(self.partner_4_supplied_products.ids)
75-
)
74+
self.assertEqual(set(supplied_product), set(self.partner_supplied_products.ids))

purchase_allowed_product/views/account_move_views.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
<field name="model">account.move</field>
55
<field name="inherit_id" ref="account.view_move_form" />
66
<field name="arch" type="xml">
7-
<xpath expr="//field[@name='partner_id']/.." position="inside">
7+
<xpath expr="//group[@id='header_left_group']" position="inside">
88
<field
9-
invisible="state != 'draft' or move_type not in ('in_invoice', 'in_refund', 'in_receipt')"
109
name="use_only_supplied_product"
10+
invisible="state != 'draft' or move_type not in ('in_invoice', 'in_refund', 'in_receipt')"
1111
widget="boolean_toggle"
1212
/>
1313
</xpath>
1414
<xpath
15-
expr="//field[@name='invoice_line_ids']/tree/field[@name='product_id']"
15+
expr="//field[@name='invoice_line_ids']/list/field[@name='product_id']"
1616
position="attributes"
1717
>
1818
<attribute name="context">

purchase_allowed_product/views/purchase_order_views.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<field name="use_only_supplied_product" widget="boolean_toggle" />
99
</xpath>
1010
<xpath
11-
expr="//field[@name='order_line']/tree/field[@name='product_id']"
11+
expr="//field[@name='order_line']/list/field[@name='product_id']"
1212
position="attributes"
1313
>
1414
<attribute name="context" operation="update">

0 commit comments

Comments
 (0)