Skip to content

Commit

Permalink
[IMP] purchase_analytic: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
alan196 committed May 16, 2022
1 parent 4a2cac5 commit ab8de3d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
14 changes: 6 additions & 8 deletions purchase_analytic/models/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class PurchaseOrder(models.Model):

@api.depends("order_line.account_analytic_id")
def _compute_project_id(self):
""" If all order line have same analytic account set project_id
"""
"""If all order line have same analytic account set project_id"""
for po in self:
al = po.project_id2
if po.order_line:
Expand All @@ -37,19 +36,18 @@ def _compute_project_id(self):
po.project_id = al

def _inverse_project_id(self):
""" When set project_id set analytic account on all order lines
"""
"""When set project_id set analytic account on all order lines"""
for po in self:
if po.project_id:
po.order_line.write({"account_analytic_id": po.project_id.id})
po.project_id2 = po.project_id

@api.onchange("project_id")
def _onchange_project_id(self):
""" When change project_id set analytic account on all order lines
Do it in one operation to avoid to recompute the project_id field
during the change.
In case of new record, nothing is recomputed to avoid ugly message
"""When change project_id set analytic account on all order lines
Do it in one operation to avoid to recompute the project_id field
during the change.
In case of new record, nothing is recomputed to avoid ugly message
"""
r = []
for ol in self.order_line:
Expand Down
12 changes: 6 additions & 6 deletions purchase_analytic/tests/test_purchase_analytic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def setUp(self):
)

def test_analytic_account(self):
""" Create a purchase order (create)
Set analytic account on purchase
Check analytic account on line is set
"""Create a purchase order (create)
Set analytic account on purchase
Check analytic account on line is set
"""
po = self.env["purchase.order"].create(
{
Expand All @@ -46,9 +46,9 @@ def test_analytic_account(self):
self.assertEqual(po.order_line.account_analytic_id.id, self.project.id)

def test_project_id(self):
""" Create a purchase order (new)
Set analytic account on purchase
Check analytic account is on purchase
"""Create a purchase order (new)
Set analytic account on purchase
Check analytic account is on purchase
"""
po = self.env["purchase.order"].new(
{
Expand Down
1 change: 1 addition & 0 deletions setup/purchase_analytic/odoo/addons/purchase_analytic
6 changes: 6 additions & 0 deletions setup/purchase_analytic/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit ab8de3d

Please sign in to comment.