Skip to content

Commit c259180

Browse files
committed
[IMP] purchase_order_line_sequence: black, isort, prettier
1 parent 599e022 commit c259180

File tree

9 files changed

+204
-146
lines changed

9 files changed

+204
-146
lines changed

purchase_order_line_sequence/__manifest__.py

+22-19
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,27 @@
44
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
55

66
{
7-
'name': 'Purchase Order Line Sequence',
8-
'summary': 'Adds sequence to PO lines and propagates it to'
9-
'Invoice lines and Stock Moves',
10-
'version': '12.0.1.0.1',
11-
'category': 'Purchase Management',
12-
'author': "Camptocamp, "
13-
"Eficent, "
14-
"Serpent CS, "
15-
"Odoo Community Association (OCA)",
16-
'website': 'https://github.com/OCA/purchase-workflow',
17-
'depends': [
18-
'purchase_stock', 'stock_picking_line_sequence',
7+
"name": "Purchase Order Line Sequence",
8+
"summary": "Adds sequence to PO lines and propagates it to"
9+
"Invoice lines and Stock Moves",
10+
"version": "14.0.1.0.0",
11+
"category": "Purchase Management",
12+
"author": "Camptocamp, "
13+
"Eficent, "
14+
"Serpent CS, "
15+
"Odoo Community Association (OCA)",
16+
"website": "https://github.com/OCA/purchase-workflow",
17+
"depends": [
18+
"purchase_stock",
19+
"stock_picking_line_sequence",
1920
],
20-
'data': ['views/purchase_view.xml',
21-
'views/report_purchaseorder.xml',
22-
'views/report_purchasequotation.xml'],
23-
'post_init_hook': 'post_init_hook',
24-
'installable': True,
25-
'auto_install': False,
26-
'license': "AGPL-3",
21+
"data": [
22+
"views/purchase_view.xml",
23+
"views/report_purchaseorder.xml",
24+
"views/report_purchasequotation.xml",
25+
],
26+
"post_init_hook": "post_init_hook",
27+
"installable": True,
28+
"auto_install": False,
29+
"license": "AGPL-3",
2730
}

purchase_order_line_sequence/hooks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ def post_init_hook(cr, pool):
1111
Fetches all the PO and resets the sequence of the purchase order lines.
1212
"""
1313
env = Environment(cr, SUPERUSER_ID, {})
14-
purchase = env['purchase.order'].search([])
14+
purchase = env["purchase.order"].search([])
1515
purchase._reset_sequence()

purchase_order_line_sequence/models/invoice.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class AccountInvoiceLine(models.Model):
10-
_inherit = 'account.invoice.line'
10+
_inherit = "account.invoice.line"
1111

1212
def _set_additional_fields(self, invoice):
1313
if self.purchase_line_id:

purchase_order_line_sequence/models/purchase.py

+35-24
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88

99
class PurchaseOrder(models.Model):
10-
_inherit = 'purchase.order'
10+
_inherit = "purchase.order"
1111

1212
@api.multi
13-
@api.depends('order_line')
13+
@api.depends("order_line")
1414
def _compute_max_line_sequence(self):
1515
"""Allow to know the highest sequence entered in purchase order lines.
1616
Then we add 1 to this value for the next sequence which is given
@@ -19,25 +19,32 @@ def _compute_max_line_sequence(self):
1919
"""
2020
for purchase in self:
2121
purchase.max_line_sequence = (
22-
max(purchase.mapped('order_line.sequence') or [0]) + 1)
22+
max(purchase.mapped("order_line.sequence") or [0]) + 1
23+
)
2324

24-
max_line_sequence = fields.Integer(string='Max sequence in lines',
25-
compute='_compute_max_line_sequence')
25+
max_line_sequence = fields.Integer(
26+
string="Max sequence in lines", compute="_compute_max_line_sequence"
27+
)
2628

2729
@api.multi
2830
def _create_picking(self):
2931
res = super(PurchaseOrder, self)._create_picking()
3032
for order in self:
31-
if any([ptype in ['product', 'consu'] for ptype in
32-
order.order_line.mapped('product_id.type')]):
33+
if any(
34+
[
35+
ptype in ["product", "consu"]
36+
for ptype in order.order_line.mapped("product_id.type")
37+
]
38+
):
3339
pickings = order.picking_ids.filtered(
34-
lambda x: x.state not in ('done', 'cancel'))
40+
lambda x: x.state not in ("done", "cancel")
41+
)
3542
if pickings:
3643
picking = pickings[0]
3744
for move, line in zip(
38-
sorted(picking.move_lines,
39-
key=lambda m: m.id), order.order_line):
40-
move.write({'sequence': line.sequence})
45+
sorted(picking.move_lines, key=lambda m: m.id), order.order_line
46+
):
47+
move.write({"sequence": line.sequence})
4148
return res
4249

4350
@api.multi
@@ -56,23 +63,27 @@ def write(self, line_values):
5663

5764
@api.multi
5865
def copy(self, default=None):
59-
return super(PurchaseOrder,
60-
self.with_context(keep_line_sequence=True)).copy(default)
66+
return super(PurchaseOrder, self.with_context(keep_line_sequence=True)).copy(
67+
default
68+
)
6169

6270

6371
class PurchaseOrderLine(models.Model):
64-
_inherit = 'purchase.order.line'
65-
_order = 'sequence, id'
72+
_inherit = "purchase.order.line"
73+
_order = "sequence, id"
6674

67-
sequence = fields.Integer('Hidden Sequence',
68-
help="Gives the sequence of the line when "
69-
"displaying the purchase order.",
70-
default=9999)
75+
sequence = fields.Integer(
76+
"Hidden Sequence",
77+
help="Gives the sequence of the line when " "displaying the purchase order.",
78+
default=9999,
79+
)
7180

72-
sequence2 = fields.Integer('Sequence',
73-
help="Displays the sequence of the line in "
74-
"the purchase order.",
75-
related='sequence', readonly=True)
81+
sequence2 = fields.Integer(
82+
"Sequence",
83+
help="Displays the sequence of the line in " "the purchase order.",
84+
related="sequence",
85+
readonly=True,
86+
)
7687

7788
@api.multi
7889
def _prepare_stock_moves(self, picking):
@@ -85,6 +96,6 @@ def _prepare_stock_moves(self, picking):
8596
def create(self, values):
8697
line = super(PurchaseOrderLine, self).create(values)
8798
# We do not reset the sequence when copying an entire purchase order
88-
if not self.env.context.get('keep_line_sequence'):
99+
if not self.env.context.get("keep_line_sequence"):
89100
line.order_id._reset_sequence()
90101
return line
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
In standard odoo is possible to sort the purchase order lines and those are propagated to the invoice lines
2+
In standard odoo is possible to sort the purchase order lines and those are propagated to the invoice lines

0 commit comments

Comments
 (0)