Skip to content

Commit

Permalink
[MIG] delivery_free_fee_removal: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Tran committed Nov 28, 2024
1 parent 2a815df commit 778fe6d
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 24 deletions.
4 changes: 4 additions & 0 deletions delivery_free_fee_removal/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,17 @@ Contributors
- `Trobz <https://trobz.com>`__:

- Son Ho <[email protected]>
- Nhan Tran <[email protected]>

Other credits
-------------

The migration of this module from 13.0 to 14.0 was financially supported
by Camptocamp.

The migration of this module from 15.0 to 18.0 was financially supported
by Camptocamp.

Maintainers
-----------

Expand Down
2 changes: 1 addition & 1 deletion delivery_free_fee_removal/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Delivery Free Fee Removal",
"summary": "Hide free fee lines on sales orders",
"version": "15.0.1.0.0",
"version": "18.0.1.0.0",
"category": "Delivery",
"website": "https://github.com/OCA/delivery-carrier",
"author": "Tecnativa, Camptocamp, Odoo Community Association (OCA)",
Expand Down
12 changes: 7 additions & 5 deletions delivery_free_fee_removal/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ def action_confirm(self):
res = super().action_confirm()
# Invoice all the free delivery line on order confirmation
# Or the order will never be fully invoiced.
delivery_lines = self.order_line.filtered(
lambda line: line.order_id.state == "sale" and line.is_free_delivery
)
for line in delivery_lines:
line.qty_delivered = line.qty_invoiced = line.product_uom_qty
for order in self:
delivery_lines = order.order_line.filtered(
lambda line, order=order: order.state == "sale"
and line.is_free_delivery
)
for line in delivery_lines:
line.qty_delivered = line.qty_invoiced = line.product_uom_qty
return res
1 change: 1 addition & 0 deletions delivery_free_fee_removal/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
- [Trobz](https://trobz.com):

> - Son Ho \<<[email protected]>\>
> - Nhan Tran \<<[email protected]>\>
3 changes: 3 additions & 0 deletions delivery_free_fee_removal/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
The migration of this module from 13.0 to 14.0 was financially supported
by Camptocamp.

The migration of this module from 15.0 to 18.0 was financially supported
by Camptocamp.
3 changes: 3 additions & 0 deletions delivery_free_fee_removal/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<blockquote>
<ul class="simple">
<li>Son Ho &lt;<a class="reference external" href="mailto:sonhd&#64;trobz.com">sonhd&#64;trobz.com</a>&gt;</li>
<li>Nhan Tran &lt;<a class="reference external" href="mailto:nhant&#64;trobz.com">nhant&#64;trobz.com</a>&gt;</li>
</ul>
</blockquote>
</li>
Expand All @@ -430,6 +431,8 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">Other credits</a></h2>
<p>The migration of this module from 13.0 to 14.0 was financially supported
by Camptocamp.</p>
<p>The migration of this module from 15.0 to 18.0 was financially supported
by Camptocamp.</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
Expand Down
24 changes: 10 additions & 14 deletions delivery_free_fee_removal/tests/test_delivery_free_fee_removal.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class TestDeliveryFreeFeeRemoval(TransactionCase):
def setUpClass(cls):
super().setUpClass()
product = cls.env["product.product"].create(
{"name": "Product", "detailed_type": "product"}
{"name": "Product", "type": "consu"}
)
product_delivery = cls.env["product.product"].create(
{
"name": "Delivery Product",
"detailed_type": "service",
"type": "service",
"invoice_policy": "delivery",
}
)
Expand Down Expand Up @@ -64,9 +64,8 @@ def test_delivery_free_fee_removal_with_fee(self):
}
],
)
res = self.report_obj._get_report_from_name(
"sale.report_saleorder"
)._render_qweb_text(self.sale.ids, False)
report = self.report_obj._get_report_from_name("sale.report_saleorder")
res = report._render_qweb_text(report, self.sale.ids, False)
self.assertRegex(str(res[0]), "Test Delivery")

def test_delivery_free_fee_removal_with_fee_invoice_policy_delivery(self):
Expand All @@ -85,9 +84,8 @@ def test_delivery_free_fee_removal_with_fee_invoice_policy_delivery(self):
}
],
)
res = self.report_obj._get_report_from_name(
"sale.report_saleorder"
)._render_qweb_text(self.sale.ids, False)
report = self.report_obj._get_report_from_name("sale.report_saleorder")
res = report._render_qweb_text(report, self.sale.ids, False)
self.assertRegex(str(res[0]), "Test Delivery")

def test_delivery_free_fee_removal_free_fee(self):
Expand All @@ -105,9 +103,8 @@ def test_delivery_free_fee_removal_free_fee(self):
}
],
)
res = self.report_obj._get_report_from_name(
"sale.report_saleorder"
)._render_qweb_text(self.sale.ids, False)
report = self.report_obj._get_report_from_name("sale.report_saleorder")
res = report._render_qweb_text(report, self.sale.ids, False)
self.assertNotRegex(str(res[0]), "Test Delivery")

def test_delivery_free_fee_removal_free_fee_invoice_policy_order(self):
Expand All @@ -126,7 +123,6 @@ def test_delivery_free_fee_removal_free_fee_invoice_policy_order(self):
}
],
)
res = self.report_obj._get_report_from_name(
"sale.report_saleorder"
)._render_qweb_text(self.sale.ids, False)
report = self.report_obj._get_report_from_name("sale.report_saleorder")
res = report._render_qweb_text(report, self.sale.ids, False)
self.assertNotRegex(str(res[0]), "Test Delivery")
5 changes: 1 addition & 4 deletions delivery_free_fee_removal/views/sale_order_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
<field name="model">sale.order</field>
<field name="inherit_id" ref="delivery.view_order_form_with_carrier" />
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/tree" position="inside">
<field name="is_free_delivery" invisible="1" />
</xpath>
<xpath expr="//field[@name='order_line']/tree" position="attributes">
<xpath expr="//field[@name='order_line']/list" position="attributes">
<attribute name="decoration-muted">is_free_delivery</attribute>
</xpath>
</field>
Expand Down

0 comments on commit 778fe6d

Please sign in to comment.