Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
5
sale_order_priority/models/__init__.py
Executable file
5
sale_order_priority/models/__init__.py
Executable file
@@ -0,0 +1,5 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import sale_order
|
||||
from . import sale_order_line
|
||||
from . import stock_move
|
||||
36
sale_order_priority/models/sale_order.py
Executable file
36
sale_order_priority/models/sale_order.py
Executable file
@@ -0,0 +1,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
|
||||
12
sale_order_priority/models/sale_order_line.py
Executable file
12
sale_order_priority/models/sale_order_line.py
Executable file
@@ -0,0 +1,12 @@
|
||||
# Copyright 2018 Simone Rubino - Agile Business Group
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
from odoo.addons.stock.models import stock_move
|
||||
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = "sale.order.line"
|
||||
|
||||
priority = fields.Selection(stock_move.PROCUREMENT_PRIORITIES, default="0")
|
||||
11
sale_order_priority/models/stock_move.py
Executable file
11
sale_order_priority/models/stock_move.py
Executable file
@@ -0,0 +1,11 @@
|
||||
from odoo import models
|
||||
|
||||
|
||||
class StockMove(models.Model):
|
||||
_inherit = "stock.move"
|
||||
|
||||
def _get_new_picking_values(self):
|
||||
picking_values = super()._get_new_picking_values()
|
||||
if self.group_id.sale_id.priority:
|
||||
picking_values["priority"] = self.group_id.sale_id.priority
|
||||
return picking_values
|
||||
Reference in New Issue
Block a user