Skip to content

Commit

Permalink
[MIG] sale_order_general_discount: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeliconiaSolutions committed Dec 13, 2024
1 parent 2876d9c commit ddbbfe6
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 78 deletions.
3 changes: 2 additions & 1 deletion sale_order_general_discount/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Sale Order General Discount
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a4eeadfa3e2fc4ad9f54244dc002a32d12938c91207c4f729001730ca727a156
!! source digest: sha256:dae30a736c327172b8cf10b83644dc4e2e475ea9f9f02596c3c201ab4143e52c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
Expand Down Expand Up @@ -87,6 +87,7 @@ Contributors

- Raf Ven <[email protected]>
- Sudhir Arya <[email protected]>
- Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion sale_order_general_discount/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Sale Order General Discount",
"summary": "General discount per sale order",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"development_status": "Production/Stable",
"category": "Sales",
"website": "https://github.com/OCA/sale-workflow",
Expand Down
1 change: 0 additions & 1 deletion sale_order_general_discount/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class ProductProduct(models.Model):
_inherit = "product.product"

bypass_general_discount = fields.Boolean(
string="Don't apply general discount",
help="If this checkbox is not ticked, it means changing general discount on "
"sale order will impact sale order lines with this related product.",
)
1 change: 0 additions & 1 deletion sale_order_general_discount/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class ProductTemplate(models.Model):
_inherit = "product.template"

bypass_general_discount = fields.Boolean(
string="Don't apply general discount",
compute="_compute_bypass_general_discount",
inverse="_inverse_bypass_general_discount",
search="_search_bypass_general_discount",
Expand Down
1 change: 0 additions & 1 deletion sale_order_general_discount/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class ResPartner(models.Model):
_inherit = "res.partner"

sale_discount = fields.Float(
string="Discount",
digits="Discount",
company_dependent=True,
)
Expand Down
1 change: 0 additions & 1 deletion sale_order_general_discount/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class SaleOrder(models.Model):
_inherit = "sale.order"

general_discount = fields.Float(
string="Discount (%)",
compute="_compute_general_discount",
store=True,
readonly=False,
Expand Down
1 change: 1 addition & 0 deletions sale_order_general_discount/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
- Stefan Ungureanu \<<[email protected]>\>
- Raf Ven \<<[email protected]>\>
- Sudhir Arya \<<[email protected]>\>
- Heliconia Solutions Pvt. Ltd. \<<https://www.heliconia.io>\>
3 changes: 2 additions & 1 deletion sale_order_general_discount/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Sale Order General Discount</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a4eeadfa3e2fc4ad9f54244dc002a32d12938c91207c4f729001730ca727a156
!! source digest: sha256:dae30a736c327172b8cf10b83644dc4e2e475ea9f9f02596c3c201ab4143e52c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-workflow/tree/18.0/sale_order_general_discount"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_order_general_discount"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to set a general discount in a sales order. This
Expand Down Expand Up @@ -434,6 +434,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
</li>
<li>Raf Ven &lt;<a class="reference external" href="mailto:raf.ven&#64;dynapps.be">raf.ven&#64;dynapps.be</a>&gt;</li>
<li>Sudhir Arya &lt;<a class="reference external" href="mailto:sudhir&#64;erpharbor.com">sudhir&#64;erpharbor.com</a>&gt;</li>
<li>Heliconia Solutions Pvt. Ltd. &lt;<a class="reference external" href="https://www.heliconia.io">https://www.heliconia.io</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
138 changes: 74 additions & 64 deletions sale_order_general_discount/tests/test_sale_order_general_discount.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,76 +10,84 @@ class TestSaleOrderLineInput(TransactionCase):
def setUpClass(cls):
super().setUpClass()
cls.partner = cls.env["res.partner"].create(
{"name": "Test", "sale_discount": 10.0}
[{"name": "Test", "sale_discount": 10.0}]
)
cls.contact = cls.env["res.partner"].create(
{
"name": "Contact Test",
"parent_id": cls.partner.id,
"type": "contact",
}
[
{
"name": "Contact Test",
"parent_id": cls.partner.id,
"type": "contact",
}
]
)
cls.product = cls.env["product.product"].create(
{"name": "test_product", "type": "service"}
[{"name": "test_product", "type": "service"}]
)
cls.pricelist = cls.env["product.pricelist"].create(
{"name": "Public Pricelist", "sequence": 1}
[{"name": "Public Pricelist", "sequence": 1}]
)
cls.product2 = cls.env["product.product"].create(
{
"name": "test product without general discount",
"type": "service",
"bypass_general_discount": True,
}
[
{
"name": "test product without general discount",
"type": "service",
"bypass_general_discount": True,
}
]
)
cls.order = cls.env["sale.order"].create(
{
"partner_id": cls.partner.id,
"order_line": [
(
0,
0,
{
"name": cls.product.name,
"product_id": cls.product.id,
"product_uom_qty": 1,
"product_uom": cls.product.uom_id.id,
"price_unit": 1000.00,
},
),
(
0,
0,
{
"name": cls.product2.name,
"product_id": cls.product2.id,
"product_uom_qty": 1,
"product_uom": cls.product2.uom_id.id,
"price_unit": 1000.00,
},
),
],
"pricelist_id": cls.pricelist.id,
}
[
{
"partner_id": cls.partner.id,
"order_line": [
(
0,
0,
{
"name": cls.product.name,
"product_id": cls.product.id,
"product_uom_qty": 1,
"product_uom": cls.product.uom_id.id,
"price_unit": 1000.00,
},
),
(
0,
0,
{
"name": cls.product2.name,
"product_id": cls.product2.id,
"product_uom_qty": 1,
"product_uom": cls.product2.uom_id.id,
"price_unit": 1000.00,
},
),
],
"pricelist_id": cls.pricelist.id,
}
]
)
cls.contact_order = cls.env["sale.order"].create(
{
"partner_id": cls.contact.id,
"order_line": [
(
0,
0,
{
"name": cls.product.name,
"product_id": cls.product.id,
"product_uom_qty": 1,
"product_uom": cls.product.uom_id.id,
"price_unit": 1000.00,
},
)
],
"pricelist_id": cls.pricelist.id,
}
[
{
"partner_id": cls.contact.id,
"order_line": [
(
0,
0,
{
"name": cls.product.name,
"product_id": cls.product.id,
"product_uom_qty": 1,
"product_uom": cls.product.uom_id.id,
"price_unit": 1000.00,
},
)
],
"pricelist_id": cls.pricelist.id,
}
]
)
cls.View = cls.env["ir.ui.view"]

Expand Down Expand Up @@ -112,18 +120,20 @@ def test_default_line_discount_value(self):
ctx = self._get_ctx_from_view(res)
self.assertTrue("default_discount" in ctx)
view = self.View.create(
{
"name": "test",
"type": "form",
"model": "sale.order",
"arch": """
[
{
"name": "test",
"type": "form",
"model": "sale.order",
"arch": """
<form>
<field name='order_line'
context="{'default_product_uom_qty': 3.0}">
</field>
</form>
""",
}
}
]
)
res = self.order.get_view(view_id=view.id, view_type="form")
ctx = self._get_ctx_from_view(res)
Expand Down
6 changes: 5 additions & 1 deletion sale_order_general_discount/views/product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
<field name="inherit_id" ref="product.product_normal_form_view" />
<field name="arch" type="xml">
<xpath expr="//group[@name='group_standard_price']" position="inside">
<field name="bypass_general_discount" />
<field
name="bypass_general_discount"
string="Don't apply general discount"
/>
</xpath>
</field>
</record>
Expand All @@ -20,6 +23,7 @@
<xpath expr="//group[@name='group_standard_price']" position="inside">
<field
name="bypass_general_discount"
string="Don't apply general discount"
invisible="product_variant_count > 1"
/>
</xpath>
Expand Down
2 changes: 1 addition & 1 deletion sale_order_general_discount/views/res_partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
>
<label for="sale_discount" />
<div>
<field name="sale_discount" class="oe_inline" /> %
<field name="sale_discount" string="Discount" class="oe_inline" /> %
</div>
</xpath>
</field>
Expand Down
14 changes: 9 additions & 5 deletions sale_order_general_discount/views/sale_order_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='tax_totals']" position="before">
<field
name="general_discount"
class="oe_subtotal_footer_separator"
style="width: 4.375rem;"
/>
<div class="oe_row" style="float:right;">
<label for="general_discount" />
<field
name="general_discount"
style="width: 5.5rem;"
class="oe_subtotal_footer_separator mr-0"
string="Discount (%)"
/>
</div>
</xpath>
</field>
</record>
Expand Down

0 comments on commit ddbbfe6

Please sign in to comment.