Skip to content

Commit 9ef0120

Browse files
DariosiFernandoRomera
authored andcommitted
[IMP] purchase_allowed_product: black, isort, prettier
1 parent 02d7a39 commit 9ef0120

13 files changed

+798
-503
lines changed

purchase_allowed_product/README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Purchase and Invoice Allowed Product
2323
:target: https://runbot.odoo-community.org/runbot/142/12.0
2424
:alt: Try me on Runbot
2525

26-
|badge1| |badge2| |badge3| |badge4| |badge5|
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
2727

2828
This module adds a restriction in purchase and supplier invoices that has the
2929
mark "Order and invoice only supplied products" checked for allowing to select

purchase_allowed_product/__manifest__.py

+14-16
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,19 @@
33
# 2020 Manuel Calero - Tecnativa
44
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
55
{
6-
'name': 'Purchase and Invoice Allowed Product',
7-
'summary': 'This module allows to select only products that can be '
8-
'supplied by the vendor',
9-
'version': '12.0.1.0.0',
10-
'category': 'Accounting & Finance',
11-
'website': 'https://github.com/OCA/purchase-workflow',
12-
'author': 'Akretion, Odoo Community Association (OCA)',
13-
'license': 'AGPL-3',
14-
'installable': True,
15-
'depends': [
16-
'purchase',
6+
"name": "Purchase and Invoice Allowed Product",
7+
"summary": "This module allows to select only products that can be "
8+
"supplied by the vendor",
9+
"version": "12.0.1.0.0",
10+
"category": "Accounting & Finance",
11+
"website": "https://github.com/OCA/purchase-workflow",
12+
"author": "Akretion, Odoo Community Association (OCA)",
13+
"license": "AGPL-3",
14+
"installable": True,
15+
"depends": ["purchase",],
16+
"data": [
17+
"views/res_partner_view.xml",
18+
"views/account_invoice_view.xml",
19+
"views/purchase_order_view.xml",
1720
],
18-
'data': [
19-
'views/res_partner_view.xml',
20-
'views/account_invoice_view.xml',
21-
'views/purchase_order_view.xml',
22-
]
2321
}

purchase_allowed_product/models/account_invoice.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66

77
class AccountInvoice(models.Model):
8-
_inherit = ['account.invoice', 'supplied.product.mixin']
9-
_name = 'account.invoice'
8+
_inherit = ["account.invoice", "supplied.product.mixin"]
9+
_name = "account.invoice"

purchase_allowed_product/models/product.py

+25-15
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,33 @@ class ProductProduct(models.Model):
1010
_inherit = "product.product"
1111

1212
@api.model
13-
def _search(self, args, offset=0, limit=None, order=None, count=False,
14-
access_rights_uid=None):
15-
use_only_supplied_product = self.env.context.get(
16-
'use_only_supplied_product')
13+
def _search(
14+
self,
15+
args,
16+
offset=0,
17+
limit=None,
18+
order=None,
19+
count=False,
20+
access_rights_uid=None,
21+
):
22+
use_only_supplied_product = self.env.context.get("use_only_supplied_product")
1723
if use_only_supplied_product:
18-
restrict_supplier_id = self.env.context.get('restrict_supplier_id')
19-
seller = self.env['res.partner'].browse(restrict_supplier_id)
24+
restrict_supplier_id = self.env.context.get("restrict_supplier_id")
25+
seller = self.env["res.partner"].browse(restrict_supplier_id)
2026
seller = seller.commercial_partner_id
21-
supplierinfos = self.env['product.supplierinfo'].search(
22-
[('name', '=', seller.id)])
27+
supplierinfos = self.env["product.supplierinfo"].search(
28+
[("name", "=", seller.id)]
29+
)
2330
args += [
24-
'|',
25-
('product_tmpl_id', 'in',
26-
supplierinfos.mapped('product_tmpl_id').ids),
27-
('id', 'in',
28-
supplierinfos.mapped('product_id').ids)
31+
"|",
32+
("product_tmpl_id", "in", supplierinfos.mapped("product_tmpl_id").ids),
33+
("id", "in", supplierinfos.mapped("product_id").ids),
2934
]
3035
return super()._search(
31-
args, offset=offset, limit=limit, order=order, count=count,
32-
access_rights_uid=access_rights_uid)
36+
args,
37+
offset=offset,
38+
limit=limit,
39+
order=order,
40+
count=count,
41+
access_rights_uid=access_rights_uid,
42+
)

purchase_allowed_product/models/product_supplierinfo.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55

66

77
class ProductSupplierinfo(models.Model):
8-
_inherit = 'product.supplierinfo'
8+
_inherit = "product.supplierinfo"
99

10-
name = fields.Many2one('res.partner', index=True)
10+
name = fields.Many2one("res.partner", index=True)

purchase_allowed_product/models/purchase_order.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66

77
class PurchaseOrder(models.Model):
8-
_inherit = ['purchase.order', 'supplied.product.mixin']
9-
_name = 'purchase.order'
8+
_inherit = ["purchase.order", "supplied.product.mixin"]
9+
_name = "purchase.order"
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# © 2016 Chafique DELLI @ Akretion
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
33

4-
from odoo import models, fields
4+
from odoo import fields, models
55

66

77
class ResPartner(models.Model):
@@ -10,6 +10,7 @@ class ResPartner(models.Model):
1010
use_only_supplied_product = fields.Boolean(
1111
string="Order and invoice only supplied products",
1212
help="If checked, by default you will only be able to select products"
13-
" that can be supplied by this supplier when creating a supplier"
14-
" invoice or purchase for it."
15-
" This value can be changed by invoice or purchase.")
13+
" that can be supplied by this supplier when creating a supplier"
14+
" invoice or purchase for it."
15+
" This value can be changed by invoice or purchase.",
16+
)

purchase_allowed_product/models/supplied_product_mixin.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55

66

77
class SuppliedProductMixin(models.AbstractModel):
8-
_name = 'supplied.product.mixin'
8+
_name = "supplied.product.mixin"
99
_description = "Mixin for documents that want to restrict products"
1010

1111
use_only_supplied_product = fields.Boolean(
1212
string="Use only allowed products",
1313
help="If checked, only the products provided by this supplier "
14-
"will be shown.")
14+
"will be shown.",
15+
)
1516

16-
@api.onchange('partner_id')
17+
@api.onchange("partner_id")
1718
def partner_id_change(self):
1819
only_supp_prod = self.partner_id.use_only_supplied_product
1920
if not only_supp_prod:
20-
only_supp_prod = self.partner_id.commercial_partner_id.\
21-
use_only_supplied_product
21+
only_supp_prod = (
22+
self.partner_id.commercial_partner_id.use_only_supplied_product
23+
)
2224
self.use_only_supplied_product = only_supp_prod

0 commit comments

Comments
 (0)