Skip to content

Commit 9228b40

Browse files
committed
Merge PR #2737 into 16.0
Signed-off-by rousseldenis
2 parents acfa453 + 614f132 commit 9228b40

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

sale_order_general_discount/models/sale_order.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ def _compute_general_discount(self):
2121
for so in self:
2222
so.general_discount = so.partner_id.sale_discount
2323

24+
@api.model
25+
def _get_discount_field_to_replace(self):
26+
return "discount"
27+
2428
@api.model
2529
def get_view(self, view_id=None, view_type="form", **options):
2630
"""The purpose of this is to write a context on "order_line" field
@@ -37,7 +41,9 @@ def get_view(self, view_id=None, view_type="form", **options):
3741
order_line_field = order_line_fields[0]
3842
context = order_line_field.attrib.get("context", "{}").replace(
3943
"{",
40-
"{'default_discount': general_discount, ",
44+
"{{'default_{}': general_discount, ".format(
45+
self._get_discount_field_to_replace()
46+
),
4147
1,
4248
)
4349
order_line_field.attrib["context"] = context

sale_order_general_discount_triple/models/sale_order.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ def _create_delivery_line(self, carrier, price_unit):
2424
line._compute_discount2()
2525
line._compute_discount3()
2626
return res
27+
28+
@api.model
29+
def _get_discount_field_to_replace(self):
30+
return self.env["sale.order.line"]._get_discount_field_position(
31+
"general_discount"
32+
)

0 commit comments

Comments
 (0)