forked from OCA/sale-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsale_order.py
More file actions
36 lines (29 loc) · 1.13 KB
/
sale_order.py
File metadata and controls
36 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Copyright 2018 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
from odoo.addons.stock.models import stock_move
class SaleOrder(models.Model):
_inherit = "sale.order"
priority = fields.Selection(
stock_move.PROCUREMENT_PRIORITIES,
compute="_compute_priority",
inverse="_inverse_priority",
store=True,
index=True,
tracking=True,
help="Priority for this sale order. "
"Setting manually a value here would set it as priority "
"for all the order lines",
)
@api.depends("order_line.priority")
def _compute_priority(self):
for order in self.filtered(lambda x: x.order_line):
priority = order.mapped("order_line.priority")
order.priority = max([x for x in priority if x] or "0")
def _inverse_priority(self):
for order in self:
priority = order.priority
for line in order.order_line.filtered(
lambda x, pr=priority: x.priority != pr
):
line.priority = priority