From e43b79eade281356071d98a78d9f36afc193fd94 Mon Sep 17 00:00:00 2001 From: ahiexp Date: Tue, 1 Jul 2025 09:13:46 +0400 Subject: [PATCH 1/3] [FIX] fix sale order on donation 'Free Amount' case --- .../ensan_sale_management/models/sale_order.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/odex25_donation/ensan_sale_management/models/sale_order.py b/odex25_donation/ensan_sale_management/models/sale_order.py index 08d3acfa6..8dc506f44 100644 --- a/odex25_donation/ensan_sale_management/models/sale_order.py +++ b/odex25_donation/ensan_sale_management/models/sale_order.py @@ -44,11 +44,15 @@ class SaleOrder(models.Model): for sale in self: sale.sale_order_portal_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') + sale.get_portal_url() - def _cart_update(self, *args, **kwargs): - res = super()._cart_update(*args, **kwargs) + def _cart_update(self, product_id=None, line_id=None, add_qty=0, set_qty=0, **kwargs): + res = super()._cart_update(product_id=product_id, + line_id=line_id, + add_qty=add_qty, + set_qty=set_qty, + **kwargs) order_line = self.env['sale.order.line'].browse(res.get('line_id')) - qty = kwargs.get('add_qty', False) or kwargs.get('set_qty', False) + qty = add_qty or set_qty if qty and order_line: self.convert_donation_qty_to_price(order_line, qty) From a54beac143dcb0a646d75a32a749dbc8e6af6010 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Tue, 1 Jul 2025 12:04:14 +0300 Subject: [PATCH 2/3] Add or update prevent-invalid-branch-merges workflow --- .../prevent-invalid-branch-merges.yml | 304 ++++++++++++++++++ 1 file changed, 304 insertions(+) create mode 100644 .github/workflows/prevent-invalid-branch-merges.yml diff --git a/.github/workflows/prevent-invalid-branch-merges.yml b/.github/workflows/prevent-invalid-branch-merges.yml new file mode 100644 index 000000000..24bb05fbb --- /dev/null +++ b/.github/workflows/prevent-invalid-branch-merges.yml @@ -0,0 +1,304 @@ +# Author: Ahmad Samir +name: Prevent Invalid Merges + +on: + pull_request: + branches: + - dev_odex-event + - dev_odex25_accounting + - dev_odex25_base + - dev_odex25_dms + - dev_odex25_fleet + - dev_odex25_hr + - dev_odex25_inventory + - dev_odex25_maintenance + - dev_odex25_mobile + - dev_odex25_pos + - dev_odex25_project + - dev_odex25_purchase + - dev_odex25_realstate + - dev_odex25_sales + - dev_odex25_survey + - dev_odex25_transactions + - dev_odex25_website + - dev_openeducat_erp-14.0.1.0 + - dev_odex25_ensan + - dev_odex25_helpdesk + - dev_odex25_donation + + - preprod_odex-event + - preprod_odex25_accounting + - preprod_odex25_base + - preprod_odex25_dms + - preprod_odex25_fleet + - preprod_odex25_hr + - preprod_odex25_inventory + - preprod_odex25_maintenance + - preprod_odex25_mobile + - preprod_odex25_pos + - preprod_odex25_project + - preprod_odex25_purchase + - preprod_odex25_realstate + - preprod_odex25_sales + - preprod_odex25_survey + - preprod_odex25_transactions + - preprod_odex25_website + - preprod_openeducat_erp-14.0.1.0 + - preprod_odex25_ensan + - preprod_odex25_helpdesk + - preprod_odex25_donation + + - master_odex-event + - master_odex25_accounting + - master_odex25_base + - master_odex25_dms + - master_odex25_fleet + - master_odex25_hr + - master_odex25_inventory + - master_odex25_maintenance + - master_odex25_mobile + - master_odex25_pos + - master_odex25_project + - master_odex25_purchase + - master_odex25_realstate + - master_odex25_sales + - master_odex25_survey + - master_odex25_transactions + - master_odex25_website + - master_openeducat_erp-14.0.1.0 + - master_odex25_ensan + - master_odex25_helpdesk + - master_odex25_donation + + + +jobs: + validate-merge-source: + runs-on: app-sever-project-runner + steps: + - name: Check source branch for merge + run: | + echo "Base branch: ${{ github.base_ref }}" + echo "Head branch: ${{ github.head_ref }}" + + + # ✅ Preprod Branches + if [[ "${{ github.base_ref }}" == "preprod_odex-event" && "${{ github.head_ref }}" != "dev_odex-event" ]]; then + echo "::error ::You can only merge to 'preprod_odex-event' from 'dev_odex-event' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_accounting" && "${{ github.head_ref }}" != "dev_odex25_accounting" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_accounting' from 'dev_odex25_accounting' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_base" && "${{ github.head_ref }}" != "dev_odex25_base" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_base' from 'dev_odex25_base' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_dms" && "${{ github.head_ref }}" != "dev_odex25_dms" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_dms' from 'dev_odex25_dms' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_fleet" && "${{ github.head_ref }}" != "dev_odex25_fleet" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_fleet' from 'dev_odex25_fleet' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_hr" && "${{ github.head_ref }}" != "dev_odex25_hr" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_hr' from 'dev_odex25_hr' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_inventory" && "${{ github.head_ref }}" != "dev_odex25_inventory" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_inventory' from 'dev_odex25_inventory' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_maintenance" && "${{ github.head_ref }}" != "dev_odex25_maintenance" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_maintenance' from 'dev_odex25_maintenance' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_mobile" && "${{ github.head_ref }}" != "dev_odex25_mobile" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_mobile' from 'dev_odex25_mobile' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_pos" && "${{ github.head_ref }}" != "dev_odex25_pos" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_pos' from 'dev_odex25_pos' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_project" && "${{ github.head_ref }}" != "dev_odex25_project" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_project' from 'dev_odex25_project' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_purchase" && "${{ github.head_ref }}" != "dev_odex25_purchase" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_purchase' from 'dev_odex25_purchase' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_realstate" && "${{ github.head_ref }}" != "dev_odex25_realstate" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_realstate' from 'dev_odex25_realstate' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_sales" && "${{ github.head_ref }}" != "dev_odex25_sales" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_sales' from 'dev_odex25_sales' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_survey" && "${{ github.head_ref }}" != "dev_odex25_survey" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_survey' from 'dev_odex25_survey' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_transactions" && "${{ github.head_ref }}" != "dev_odex25_transactions" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_transactions' from 'dev_odex25_transactions' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_website" && "${{ github.head_ref }}" != "dev_odex25_website" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_website' from 'dev_odex25_website' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_openeducat_erp-14.0.1.0" && "${{ github.head_ref }}" != "dev_openeducat_erp-14.0.1.0" ]]; then + echo "::error ::You can only merge to 'preprod_openeducat_erp-14.0.1.0' from 'dev_openeducat_erp-14.0.1.0' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_ensan" && "${{ github.head_ref }}" != "dev_odex25_ensan" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_ensan' from 'dev_odex25_ensan' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_helpdesk" && "${{ github.head_ref }}" != "dev_odex25_helpdesk" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_helpdesk' from 'dev_odex25_helpdesk' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "preprod_odex25_donation" && "${{ github.head_ref }}" != "dev_odex25_donation" ]]; then + echo "::error ::You can only merge to 'preprod_odex25_donation' from 'dev_odex25_donation' branch!" + exit 1 + fi + + # ✅ Master Branches + if [[ "${{ github.base_ref }}" == "master_odex-event" && "${{ github.head_ref }}" != "preprod_odex-event" ]]; then + echo "::error ::You can only merge to 'master_odex-event' from 'preprod_odex-event' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_accounting" && "${{ github.head_ref }}" != "preprod_odex25_accounting" ]]; then + echo "::error ::You can only merge to 'master_odex25_accounting' from 'preprod_odex25_accounting' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_base" && "${{ github.head_ref }}" != "preprod_odex25_base" ]]; then + echo "::error ::You can only merge to 'master_odex25_base' from 'preprod_odex25_base' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_dms" && "${{ github.head_ref }}" != "preprod_odex25_dms" ]]; then + echo "::error ::You can only merge to 'master_odex25_dms' from 'preprod_odex25_dms' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_fleet" && "${{ github.head_ref }}" != "preprod_odex25_fleet" ]]; then + echo "::error ::You can only merge to 'master_odex25_fleet' from 'preprod_odex25_fleet' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_hr" && "${{ github.head_ref }}" != "preprod_odex25_hr" ]]; then + echo "::error ::You can only merge to 'master_odex25_hr' from 'preprod_odex25_hr' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_inventory" && "${{ github.head_ref }}" != "preprod_odex25_inventory" ]]; then + echo "::error ::You can only merge to 'master_odex25_inventory' from 'preprod_odex25_inventory' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_maintenance" && "${{ github.head_ref }}" != "preprod_odex25_maintenance" ]]; then + echo "::error ::You can only merge to 'master_odex25_maintenance' from 'preprod_odex25_maintenance' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_mobile" && "${{ github.head_ref }}" != "preprod_odex25_mobile" ]]; then + echo "::error ::You can only merge to 'master_odex25_mobile' from 'preprod_odex25_mobile' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_pos" && "${{ github.head_ref }}" != "preprod_odex25_pos" ]]; then + echo "::error ::You can only merge to 'master_odex25_pos' from 'preprod_odex25_pos' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_project" && "${{ github.head_ref }}" != "preprod_odex25_project" ]]; then + echo "::error ::You can only merge to 'master_odex25_project' from 'preprod_odex25_project' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_purchase" && "${{ github.head_ref }}" != "preprod_odex25_purchase" ]]; then + echo "::error ::You can only merge to 'master_odex25_purchase' from 'preprod_odex25_purchase' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_realstate" && "${{ github.head_ref }}" != "preprod_odex25_realstate" ]]; then + echo "::error ::You can only merge to 'master_odex25_realstate' from 'preprod_odex25_realstate' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_sales" && "${{ github.head_ref }}" != "preprod_odex25_sales" ]]; then + echo "::error ::You can only merge to 'master_odex25_sales' from 'preprod_odex25_sales' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_survey" && "${{ github.head_ref }}" != "preprod_odex25_survey" ]]; then + echo "::error ::You can only merge to 'master_odex25_survey' from 'preprod_odex25_survey' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_transactions" && "${{ github.head_ref }}" != "preprod_odex25_transactions" ]]; then + echo "::error ::You can only merge to 'master_odex25_transactions' from 'preprod_odex25_transactions' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_website" && "${{ github.head_ref }}" != "preprod_odex25_website" ]]; then + echo "::error ::You can only merge to 'master_odex25_website' from 'preprod_odex25_website' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_openeducat_erp-14.0.1.0" && "${{ github.head_ref }}" != "preprod_openeducat_erp-14.0.1.0" ]]; then + echo "::error ::You can only merge to 'master_openeducat_erp-14.0.1.0' from 'preprod_openeducat_erp-14.0.1.0' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_ensan" && "${{ github.head_ref }}" != "preprod_odex25_ensan" ]]; then + echo "::error ::You can only merge to 'master_odex25_ensan' from 'preprod_odex25_ensan' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_helpdesk" && "${{ github.head_ref }}" != "preprod_odex25_helpdesk" ]]; then + echo "::error ::You can only merge to 'master_odex25_helpdesk' from 'preprod_odex25_helpdesk' branch!" + exit 1 + fi + + if [[ "${{ github.base_ref }}" == "master_odex25_donation" && "${{ github.head_ref }}" != "preprod_odex25_donation" ]]; then + echo "::error ::You can only merge to 'master_odex25_donation' from 'preprod_odex25_donation' branch!" + exit 1 + fi + + + # ❌ Block ALL merges to 'master' + if [[ "${{ github.base_ref }}" == "master" ]]; then + echo "::error ::Merging to 'master' branch is not allowed!" + exit 1 + fi + + echo "Merge validation passed." \ No newline at end of file