Skip to content

Commit

Permalink
[ADD] sale_coupon_free_shipping_default_product
Browse files Browse the repository at this point in the history
  • Loading branch information
Chionne27 committed Jan 15, 2025
1 parent 339b922 commit f48404f
Show file tree
Hide file tree
Showing 16 changed files with 592 additions and 0 deletions.
83 changes: 83 additions & 0 deletions sale_coupon_free_shipping_default_product/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
=========================================
Sale coupon free shipping default product
=========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:412f63eb94f453413437a98bee6a85959543035f981f07dd871bca2848599b42
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--promotion-lightgray.png?logo=github
:target: https://github.com/OCA/sale-promotion/tree/14.0/sale_coupon_free_shipping_default_product
:alt: OCA/sale-promotion
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-promotion-14-0/sale-promotion-14-0-sale_coupon_free_shipping_default_product
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/sale-promotion&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This modules allows to set a default product for the promotions when selecting free shipping

**Table of contents**

.. contents::
:local:

Usage
=====

Go to settings and set the product you want as a default for the free shiping promotion

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-promotion/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sale-promotion/issues/new?body=module:%20sale_coupon_free_shipping_default_product%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Ooops

Contributors
~~~~~~~~~~~~

* Ooops404 <https://ooops404.com>
* Daniel Chionne <[email protected]>
* Sylwester Krasinski <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/sale-promotion <https://github.com/OCA/sale-promotion/tree/14.0/sale_coupon_free_shipping_default_product>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sale_coupon_free_shipping_default_product/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
13 changes: 13 additions & 0 deletions sale_coupon_free_shipping_default_product/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Sale coupon free shipping default product",
"summary": "avoids creating multiple free shipping products",
"version": "14.0.1.0.0",
"category": "Hidden/Tools",
"author": "Ooops, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-promotion",
"license": "LGPL-3",
"installable": True,
"depends": ["sale_management", "stock", "coupon"],
"data": ["views/res_config_settings_views.xml"],
"auto_install": False,
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
3 changes: 3 additions & 0 deletions sale_coupon_free_shipping_default_product/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import coupon_program
from . import res_config_settings
from . import res_company
15 changes: 15 additions & 0 deletions sale_coupon_free_shipping_default_product/models/coupon_program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from odoo import api, models


class CouponProgram(models.Model):
_inherit = "coupon.program"

@api.model
def create(self, vals):
if self.reward_type == "free_shipping":
product = self.env.company.free_shipping_product_default
if product:
vals["discount_line_product_id"] = product.id
program = super(CouponProgram, self).create(vals)

return program
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

free_shipping_product_default = fields.Many2one(
"product.product", string="Default promo product for free shipping"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

free_shipping_product_default = fields.Many2one(
comodel_name="product.product",
string="Default promo product for free shipping",
domain=[("type", "=", "service")],
related="company_id.free_shipping_product_default",
readonly=False,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Ooops404 <https://ooops404.com>
* Daniel Chionne <[email protected]>
* Sylwester Krasinski <[email protected]>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This modules allows to set a default product for the promotions when selecting free shipping
1 change: 1 addition & 0 deletions sale_coupon_free_shipping_default_product/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Go to settings and set the product you want as a default for the free shiping promotion
Loading

0 comments on commit f48404f

Please sign in to comment.