Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sale_order_general_discount/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def _compute_general_discount(self):
for so in self:
so.general_discount = so.partner_id.sale_discount

@api.model
def _get_discount_field_to_replace(self):
return "discount"

@api.model
def get_view(self, view_id=None, view_type="form", **options):
"""The purpose of this is to write a context on "order_line" field
Expand All @@ -37,7 +41,9 @@ def get_view(self, view_id=None, view_type="form", **options):
order_line_field = order_line_fields[0]
context = order_line_field.attrib.get("context", "{}").replace(
"{",
"{'default_discount': general_discount, ",
"{{'default_{}': general_discount, ".format(
self._get_discount_field_to_replace()
),
1,
)
order_line_field.attrib["context"] = context
Expand Down
6 changes: 6 additions & 0 deletions sale_order_general_discount_triple/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ def _create_delivery_line(self, carrier, price_unit):
line._compute_discount2()
line._compute_discount3()
return res

@api.model
def _get_discount_field_to_replace(self):
return self.env["sale.order.line"]._get_discount_field_position(
"general_discount"
)