Skip to content

Commit d00c11b

Browse files
committed
Merge PR #3783 into 15.0
Signed-off-by pedrobaeza
2 parents 8dfa166 + fcae047 commit d00c11b

File tree

3 files changed

+33
-45
lines changed

3 files changed

+33
-45
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2-
from . import stock_rule
2+
from . import sale_order
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2025 Tecnativa - Carlos Dauden
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
3+
4+
from odoo import models
5+
from odoo.tools import float_round
6+
7+
8+
class SaleOrderLine(models.Model):
9+
_inherit = "sale.order.line"
10+
11+
def _prepare_procurement_values(self, group_id=False):
12+
values = super()._prepare_procurement_values(group_id)
13+
values["secondary_uom_id"] = self.secondary_uom_id.id
14+
values["secondary_uom_qty"] = self.env.context.get(
15+
"procure_secondary_uom_qty", {}
16+
).get(self.id, self.secondary_uom_qty)
17+
return values
18+
19+
def write(self, vals):
20+
if "secondary_uom_qty" in vals:
21+
lines = self.filtered(lambda r: r.state == "sale" and not r.is_expense)
22+
procure_secondary_uom_qty = {
23+
line.id: float_round(
24+
vals["secondary_uom_qty"] - line.secondary_uom_qty,
25+
precision_rounding=self.secondary_uom_id.uom_id.rounding or 0.01,
26+
)
27+
for line in lines
28+
}
29+
self = self.with_context(
30+
procure_secondary_uom_qty=procure_secondary_uom_qty
31+
)
32+
return super().write(vals)

sale_stock_secondary_unit/models/stock_rule.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)