Skip to content

Commit 5bcef03

Browse files
benwilligdsolanki-initos
authored andcommitted
[FIX] pre-commit
1 parent 3bbb9c6 commit 5bcef03

File tree

8 files changed

+83
-94
lines changed

8 files changed

+83
-94
lines changed

purchase_fop_shipping/__manifest__.py

+12-14
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@
44

55
{
66
"name": "Purchase Free-Of-Paiment shipping",
7-
'version': '13.0.1.0.0',
8-
'author': "Akretion,Odoo Community Association (OCA)",
9-
'website': "https://github.com/OCA/purchase-workflow",
10-
'maintainer': 'Akretion',
11-
'license': 'AGPL-3',
12-
'category': 'Purchase',
13-
'depends': [
14-
'purchase',
7+
"version": "13.0.1.0.0",
8+
"author": "Akretion,Odoo Community Association (OCA)",
9+
"website": "https://github.com/OCA/purchase-workflow",
10+
"maintainer": "Akretion",
11+
"license": "AGPL-3",
12+
"category": "Purchase",
13+
"depends": ["purchase"],
14+
"data": [
15+
"security/res_groups.xml",
16+
"views/purchase_order.xml",
17+
"views/res_partner.xml",
1518
],
16-
'data': [
17-
'security/res_groups.xml',
18-
'views/purchase_order.xml',
19-
'views/res_partner.xml',
20-
],
21-
'installable': True,
19+
"installable": True,
2220
}
-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
21
from . import partner
32
from . import purchase

purchase_fop_shipping/models/partner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ class ResPartner(models.Model):
1313
string="FOP shipping",
1414
help="Min purchase order amount for FOP shipping",
1515
company_dependent=True,
16-
digits='Account',
16+
digits="Account",
1717
)

purchase_fop_shipping/models/purchase.py

+18-19
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# @author Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
44

5-
from odoo import models, fields, api, _
5+
from odoo import _, api, fields, models
66
from odoo.exceptions import UserError
77
from odoo.tools import float_compare
88

@@ -12,30 +12,27 @@ class PurchaseOrder(models.Model):
1212
_inherit = "purchase.order"
1313

1414
fop_reached = fields.Boolean(
15-
string='FOP reached',
16-
help='Free-Of-Payment shipping reached',
17-
compute='_compute_fop_shipping_reached'
15+
string="FOP reached",
16+
help="Free-Of-Payment shipping reached",
17+
compute="_compute_fop_shipping_reached",
1818
)
1919
force_order_under_fop = fields.Boolean(
20-
string='Confirm under FOP',
21-
help='Force confirm purchase order under Free-Of-Payment shipping',
20+
string="Confirm under FOP",
21+
help="Force confirm purchase order under Free-Of-Payment shipping",
2222
)
2323
fop_shipping = fields.Float(
24-
string='FOP shipping',
25-
related='partner_id.fop_shipping',
24+
string="FOP shipping",
25+
related="partner_id.fop_shipping",
2626
related_sudo=False,
2727
readonly=True,
28-
help='Min purchase order amount for Free-Of-Payment shipping',
28+
help="Min purchase order amount for Free-Of-Payment shipping",
2929
)
3030

3131
@api.depends(
32-
'amount_total',
33-
'partner_id.fop_shipping',
32+
"amount_total", "partner_id.fop_shipping",
3433
)
3534
def _compute_fop_shipping_reached(self):
36-
digit_precision = self.env['decimal.precision'].precision_get(
37-
'Account'
38-
)
35+
digit_precision = self.env["decimal.precision"].precision_get("Account")
3936
for record in self:
4037
record.fop_reached = (
4138
float_compare(
@@ -54,8 +51,10 @@ def button_approve(self, force=False):
5451
def _check_fop_shipping(self):
5552
for po in self:
5653
if not po.force_order_under_fop and not po.fop_reached:
57-
raise UserError(_(
58-
'You cannot confirm a purchase order with amount under '
59-
'FOP shipping. To force confirm you must belongs to "FOP'
60-
' shipping Manager".'
61-
))
54+
raise UserError(
55+
_(
56+
"You cannot confirm a purchase order with amount under "
57+
'FOP shipping. To force confirm you must belongs to "FOP'
58+
' shipping Manager".'
59+
)
60+
)
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8" ?>
22
<odoo>
3-
43
<record id="group_fop_shipping_purchase_manager" model="res.groups">
54
<field name="name">FOP shipping Manager</field>
6-
<field name="category_id" ref="base.module_category_purchase_management"/>
7-
<field name="implied_ids" eval="[(4, ref('purchase.group_purchase_user'))]"/>
8-
<field name="users" eval="[(4, ref('base.user_root'))]"/>
5+
<field name="category_id" ref="base.module_category_purchase_management" />
6+
<field name="implied_ids" eval="[(4, ref('purchase.group_purchase_user'))]" />
7+
<field name="users" eval="[(4, ref('base.user_root'))]" />
98
</record>
10-
119
</odoo>

purchase_fop_shipping/tests/test_fop_shipping.py

+32-37
Original file line numberDiff line numberDiff line change
@@ -8,64 +8,59 @@
88

99

1010
class TestPurchaseOrder(SavepointCase):
11-
1211
@classmethod
1312
def setUpClass(cls):
1413
super(TestPurchaseOrder, cls).setUpClass()
15-
cls.Product = cls.env['product.product']
16-
cls.Purchase = cls.env['purchase.order']
17-
cls.PurchaseLine = cls.env['purchase.order.line']
14+
cls.Product = cls.env["product.product"]
15+
cls.Purchase = cls.env["purchase.order"]
16+
cls.PurchaseLine = cls.env["purchase.order.line"]
1817

19-
cls.product_1 = cls.Product.create({
20-
'name': 'Product',
21-
'type': 'consu',
22-
})
18+
cls.product_1 = cls.Product.create({"name": "Product", "type": "consu"})
2319

24-
cls.partner_3 = cls.env.ref('base.res_partner_3')
20+
cls.partner_3 = cls.env.ref("base.res_partner_3")
2521
cls.partner_3.fop_shipping = 250
2622

2723
def test_fop_shipping_reached1(self):
28-
po = self.Purchase.create({
29-
'partner_id': self.partner_3.id,
30-
})
31-
self.PurchaseLine.create({
32-
'order_id': po.id,
33-
'product_id': self.product_1.id,
34-
'date_planned': fields.Datetime.now(),
35-
'name': 'Test',
36-
'product_qty': 1.0,
37-
'product_uom': self.product_1.uom_id.id,
38-
'price_unit': 100.0,
39-
})
24+
po = self.Purchase.create({"partner_id": self.partner_3.id})
25+
self.PurchaseLine.create(
26+
{
27+
"order_id": po.id,
28+
"product_id": self.product_1.id,
29+
"date_planned": fields.Datetime.now(),
30+
"name": "Test",
31+
"product_qty": 1.0,
32+
"product_uom": self.product_1.uom_id.id,
33+
"price_unit": 100.0,
34+
}
35+
)
4036

4137
self.assertFalse(po.fop_reached)
4238

4339
with self.assertRaises(UserError) as e, self.env.cr.savepoint():
4440
po.button_approve()
4541
self.assertTrue(
4642
"You cannot confirm a purchase order with amount under "
47-
"FOP shipping"
48-
in e.exception.name
43+
"FOP shipping" in e.exception.name
4944
)
5045

5146
po.force_order_under_fop = True
5247
po.button_approve()
53-
self.assertEqual(po.state, 'purchase')
48+
self.assertEqual(po.state, "purchase")
5449

5550
def test_fop_shipping_reached2(self):
56-
po = self.Purchase.create({
57-
'partner_id': self.partner_3.id,
58-
})
59-
self.PurchaseLine.create({
60-
'order_id': po.id,
61-
'product_id': self.product_1.id,
62-
'date_planned': fields.Datetime.now(),
63-
'name': 'Test',
64-
'product_qty': 10,
65-
'product_uom': self.product_1.uom_id.id,
66-
'price_unit': 45,
67-
})
51+
po = self.Purchase.create({"partner_id": self.partner_3.id})
52+
self.PurchaseLine.create(
53+
{
54+
"order_id": po.id,
55+
"product_id": self.product_1.id,
56+
"date_planned": fields.Datetime.now(),
57+
"name": "Test",
58+
"product_qty": 10,
59+
"product_uom": self.product_1.uom_id.id,
60+
"price_unit": 45,
61+
}
62+
)
6863

6964
self.assertTrue(po.fop_reached)
7065
po.button_approve()
71-
self.assertEqual(po.state, 'purchase')
66+
self.assertEqual(po.state, "purchase")
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8" ?>
22
<odoo>
3-
43
<record model="ir.ui.view" id="origin_type_purchase_order_tree">
54
<field name="model">purchase.order</field>
65
<field name="type">tree</field>
7-
<field name="inherit_id" ref="purchase.purchase_order_tree"/>
6+
<field name="inherit_id" ref="purchase.purchase_order_tree" />
87
<field name="arch" type="xml">
98
<xpath expr="//tree" position="attributes">
109
<attribute name="decoration-danger">
1110
fop_reached == False
1211
</attribute>
1312
</xpath>
1413
<field name="origin" position="after">
15-
<field name="fop_reached" optional="show"/>
14+
<field name="fop_reached" optional="show" />
1615
</field>
1716
</field>
1817
</record>
19-
2018
<record model="ir.ui.view" id="purchase_order_delivery_paid_form_view_inherit">
2119
<field name="model">purchase.order</field>
22-
<field name="inherit_id" ref="purchase.purchase_order_form"/>
20+
<field name="inherit_id" ref="purchase.purchase_order_form" />
2321
<field name="type">form</field>
2422
<field name="arch" type="xml">
2523
<xpath expr="//field[@name='partner_ref']" position="after">
26-
<field name="force_order_under_fop"
27-
groups="purchase_fop_shipping.group_fop_shipping_purchase_manager"/>
28-
<field name="fop_shipping"/>
24+
<field
25+
name="force_order_under_fop"
26+
groups="purchase_fop_shipping.group_fop_shipping_purchase_manager"
27+
/>
28+
<field name="fop_shipping" />
2929
</xpath>
3030
</field>
3131
</record>
32-
3332
</odoo>
+7-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8" ?>
22
<odoo>
3-
43
<record model="ir.ui.view" id="res_partner_form_view_fop_shipping">
54
<field name="model">res.partner</field>
65
<field name="type">form</field>
7-
<field name="inherit_id" ref="account.view_partner_property_form"/>
6+
<field name="inherit_id" ref="account.view_partner_property_form" />
87
<field name="arch" type="xml">
9-
<xpath expr="//field[@name='property_supplier_payment_term_id']" position="after">
10-
<field name="fop_shipping"/>
8+
<xpath
9+
expr="//field[@name='property_supplier_payment_term_id']"
10+
position="after"
11+
>
12+
<field name="fop_shipping" />
1113
</xpath>
1214
</field>
1315
</record>
14-
1516
</odoo>

0 commit comments

Comments
 (0)