Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] pos_loyalty: loyalty programs for POS #185

Merged
merged 4 commits into from
Jul 11, 2017
Merged

[ADD] pos_loyalty: loyalty programs for POS #185

merged 4 commits into from
Jul 11, 2017

Conversation

geluboros
Copy link
Member

Loyalty Program

This module allows you to define a loyalty program in the point of sale,
where the customers earn loyalty points and get rewards.

This module is a forward-port to v10 of the pos_loyalty module from Odoo's
saas-6 branch.
The functionality was moved to the Enterprise edition in later versions.

@legalsylvain
Copy link
Contributor

Hi @gboros-rgbconsulting. thanks a lot to back-open-port this module. i'm very interested by this feature.

I justed quickly tested on runbot. some remarks.

  1. I don't understand discount feature. Use case with 2% discount / point cost 10 / pp_currency 1 :
    Order 1 : Sale 10€. new point 10.
    order 2 : Sale 1000€. rewards : 2% or the current order = 20€.
    I was expecting to have a discount based on the points of the customer (past orders). IE rewards = 2% of 10 points = 0,20 €.
    do you know if I can configure PoS like that ? Otherwise, I'll propose a PR.

  2. I guess it's a bug (or an Odoo feature ;-)) but it is possible to click many times on rewards, that give unexpected result. Don't you think ? What about to block user to click many times on rewards button for a pos.order.

image

@legalsylvain
Copy link
Contributor

Point 1. OK, it's not very intuitive, but to do what I want, I have to set a resale reward, with a product price of 0.02. (for 2%).
sample with a customer with 75 points.
image

point 2. bug for discount product still a problem.

@geluboros
Copy link
Member Author

Hi @legalsylvain,

  1. Actually, the resale reward is used to convert points into customer credit.

For example, if we set a point product with a price of 0.02 €, a customer with 100 points would have:
100 points * 0.02 € per point = 2 € credit
So if this reward is added to a sale order, a new line with -2 € will be added.
It's still a sort of discount, but it's not a percentage.

  1. You are right, a discount reward added multiple times gives an unexpected result. I will review this.

@geluboros
Copy link
Member Author

I added a new commit that limits discount rewards to one reward per order.

Copy link
Contributor

@legalsylvain legalsylvain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
Functional test.

Copy link
Contributor

@hparfr hparfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Some minor comments on the JS code.

} else if (rule.cumulative) {
self.loyalty.rules_by_category_id[category.id].unshift(rule);
} else {
self.loyalty.rules_by_category_id[category.id].push(rule);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines 43:49 and 51:57 can be factorized

return;
}

var line = this.add_product(product, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused var

return;
}

var line = this.add_product(product, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused var

return;
}

var line = this.add_product(product, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused var

'confirm': function(reward){
order.apply_reward(reward);
},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not consistent: always (like :387, :390) or never add return before }

@geluboros
Copy link
Member Author

Hi @hparfr,
First of all thanks for the revision.

I removed the returns and unused variables.
About the factorization of lines 43:49 and 51:57, I am not sure how it could be done since rules are stored in different arrays > one for products and one for categories.

@hparfr
Copy link
Contributor

hparfr commented Jun 30, 2017

I did not test, but you may try that way :

function update_rules(rules, rule, id) {
	if (!rules[id])
		rules[id] = [rule];
	else if (rule.cumulative)
		rules[id].unshift(rule);
	else
		rules[id].push(rule);
}

rules.forEach(function (rule) {
	if (rule.type == 'product')
		update_rules(self.loyalty.rules_by_product_id, rule, rule.product_id[0])
	else if (rule.type == 'category')
		update_rules(self.loyalty.rules_by_category_id, rule, self.db.get_category_by_id(rule.category_id[0]));
})

Btw, why var category = self.db.get_category_by_id(rule.category_id[0]); ?
Is category.id != rule.category_id[0] ?

@geluboros
Copy link
Member Author

Yes it is, i am not sure why a new variable was created.
This is how the code was in saas6, i adapted it to v10 but no refactorization was done.

@geluboros
Copy link
Member Author

Any prevision on merging this PR ? All the requested changes were done.

@legalsylvain
Copy link
Contributor

@hpar, is it ok for you ? regards.

@hparfr
Copy link
Contributor

hparfr commented Jul 11, 2017

👍

@legalsylvain legalsylvain merged commit 4aff4e5 into OCA:10.0 Jul 11, 2017
hparfr added a commit to akretion/pos that referenced this pull request Apr 27, 2018
* [ADD] setup.py

* [UPD] addons table in README.md

* [FIX] travis: Update travis file to new standard
* Add new matrix
* Add transifex support
* Switch coveralls to travis_after_tests_success
* Move pip requirements to requirements.txt

* OCA Transbot updated translations from Transifex

* OCA Transbot updated translations from Transifex

* [UPD] addons table in README.md

* [UPD] addons table in README.md

* Make pos_customer_display odoo9 compatible

* Fix version number of pos_customer_display

* Port pos_customer_display to v10

Remove the "Show total to customer" button, which is not need given the new user interface of the POS: the big "Payment" button has this role now.
Add README.rst

* Display relevant info on LCD when Qty/price/discount is forced via the buttons of the POS frontend

* Remove comment

* [UPD] addons table in README.md

* [ADD] setup.py

* new module pos_margin

* [PORT] 10.0 pos_margin

* [UPD] addons table in README.md

* [ADD] setup.py

* OCA Transbot updated translations from Transifex

* pos_remove_pos_category (OCA#148)

* migrate to v9 and add italian translation

* short headers

* migrate JS

* [fix] be defensive: do not assume we have a product category

* OCA Transbot updated translations from Transifex

* [MIG] pos_remove_pos_category: Migrated to 10.0

* [FIX] static javascript assets

* [UPD] addons table in README.md

* [ADD] setup.py

* OCA Transbot updated translations from Transifex

* [ADD] pos_loyalty: loyalty programs for POS (OCA#185)

* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading

* [UPD] addons table in README.md

* [ADD] setup.py

* OCA Transbot updated translations from Transifex

* OCA Transbot updated translations from Transifex

* [REM] remove pos_remove_pos_category Fix : OCA#200

* [UPD] addons table in README.md

* Revert "[REM] remove pos_remove_pos_category Fix : OCA#200"

This reverts commit 5825f0f.

* [FIX] avoid monkey patch and error on foreign key constraint

* [UPD] addons table in README.md

* pos_remove_pos_category: inherit the proper view of product.template

* [fix] compability between pos_customer_display and pos_pricelist (OCA#210)

* [fix] compability between pos_customer_display and pos_pricelist

* [UPD] addons table in README.md

* [ADD] PoS session pay invoice module

* [UPD] addons table in README.md

* [add] pos_default_payment_method

* fixup! [add] pos_default_payment_method

* [UPD] addons table in README.md

* [ADD] setup.py

* [FIX] Fix pos_customer_display with Floors in Restaurant

* Add mobule pos_backend_partner

* Update readme

Fix link to github

* Improve readme and manifest

* Add OCA dependencies for allowing tests on a not merged PR

* Fix readme, fix indent, fix bug when choosing a customer in payment pane.

* Add screenshots

* Fix screenshot path

* Update readme

* Hide button when not opened by pos

* [10.0] Remove hw_customer_display and hw_telium_payment_terminal (OCA#231)

* Remove hw_customer_display and hw_telium_payment_terminal

POSbox image runs Odoo v8, so we should maintain hw_* modules only in the 8.0 branch for the moment.

* Update requirements.txt following removal of hw_* modules

* [UPD] addons table in README.md

* update oca_dependencies

* update readme

* Update __init__

* update manifest

* update __init

* fix copyright

* fix copyright2

* update roadmap

* OCA Transbot updated translations from Transifex

* Add pos_backend_communication module

* Update readme

Fix github link

* Update readme

* Update readme.rst

* Update common.js

Fix typo

* Update readme

* [UPD] addons table in README.md

* [ADD] setup.py

* [ADD] module pos_price_to_weight (OCA#171)

* [ADD] module pos_price_to_weight

* [FIX] jslint / pylint / flake8 issues

* OCA Transbot updated translations from Transifex

* [MIG] pos_price_to_weight: Migration to 10.0

* [FIX] in v10, we can add value to selection fieldw

* [UPD] addons table in README.md

* [ADD] setup.py

* [FIX] website URI

* [FIX] website URI

* remove duplicated act_windows

* [ADD] new module pos_quick_logout (OCA#116)

* OCA Transbot updated translations from Transifex

* OCA Transbot updated translations from Transifex

* [MIG] pos_quick_logout: Migration to 10.0

[FIX] Fix Travis

[FIX] Fix Licence

[FIX] rename pos_quick_logout.py to pos_config.py

[FIX] Travis

[FIX] fix javascript syntax + __manifest__ typo

[FIX] fix python syntax

[FIX] rename pos_quick_logout_view.xml to pos_config_view.xml

[FIX] Travis : remove unused imports

* [IMP] add autologout to pos_quick_logout

[IMP] it's better to launch timeout fonction with start

* [UPD] addons table in README.md

* [ADD] setup.py

* [FIX] remove outdated dependencies

* OCA Transbot updated translations from Transifex

* [ADD] new module pos_timeout

* [UPD] addons table in README.md

* [ADD] setup.py

* [FIX] fixes currencies with decimals <>2

* [MIG] pos_pricelist: Migrate to v10 by backporting from v11 (OCA#247)

This module included previously support for taxes and pricelists.

Taxes are now included in upstream Odoo v10, so that feature is removed.

The pricelist feature, however, is supported in upstream Odoo v11. Thus, to ease the migration path, that functionality has been scalpel-backported from there.

This also means a great diff between previous OCA-only code and current Odoo-backport-only code, but with the advantage that the end user gets exactly the behavior that he would have when updating to v11.

Since most of the code has been copied from Odoo, the addon now has to become LGPL, and Odoo has been added as an author.

* [FIX] pos_pricelist: Fix language file

* [UPD] addons table in README.md

* [ADD] setup.py

* [FIX] pos_pricelist: Use lower-version date comparison

The removed function was introduced in momentjs in version 2.11.0, but Odoo 10.0 ships 2.8.1, so I'm using a different comparison system here that should yield the same results without exceptions.

* [UPD] addons table in README.md

* OCA Transbot updated translations from Transifex

* [10.0][ADD] pos_lot_selection: New module (OCA#256)

* [UPD] addons table in README.md

* [ADD] setup.py

* [ADD] pos_stock_picking_invoice_link: New Module

* Add module pos_default_empty_image

Big perf improvement for loading POS if you have thousand of products
without image

* Limit lines to < 80 chars

* No new line at end of file

* Add missing credits

* description file;

* Fix line length in readme

Remove __openerp.py_.description
Remove _name
Remove unneeded contents in init

* [PORT] pos_default_empty_image courtesy @invitu

* [IMP] pos_default_empty_image courtesy @invitu

* [FIX] set has_image on 'product.product' model
[IMP] make has_image stored
[REF] improve description and add screenshots
[REF] OCA convention

* [FIX] wording + remove useless JS code

* [REF] cosmetic points

* Fix readme remarks

* [UPD] addons table in README.md

* [ADD] setup.py

* [UPD] addons table in README.md

* [ADD] setup.py

* Updated pos_product_template addon to Odoo 9

* Added Spanish translation to pos_product_template (es.po)

* [FIX] Change the version number to 9 and make module installable.

* Add readme, update manifest,

switch to short copyright headers

* Some refactorings

* Refactore db

* Refactore set_product_list

* Remove comments

* Add pos_fix_search_limit module

* add pos_fix_search_limit in manifest

* [UPD] addons table in README.md

* [ADD] setup.py

* Make the ppt inheritable
kirca pushed a commit to lambda-is/pos that referenced this pull request Sep 13, 2018
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
legalsylvain pushed a commit that referenced this pull request Nov 14, 2018
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
PierrickBrun pushed a commit to PierrickBrun/pos that referenced this pull request May 7, 2019
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
cvinh pushed a commit to invitu/pos that referenced this pull request May 29, 2019
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
robinkeunen pushed a commit to coopiteasy/pos that referenced this pull request Oct 30, 2019
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
robinkeunen pushed a commit to coopiteasy/pos that referenced this pull request Nov 7, 2019
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
wpichler pushed a commit to Callino/pos that referenced this pull request Nov 19, 2019
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
flotho pushed a commit to flotho/pos that referenced this pull request Jun 23, 2020
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
flotho pushed a commit to flotho/pos that referenced this pull request Feb 22, 2021
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
dsolanki-initos pushed a commit to initOS/pos that referenced this pull request Apr 16, 2021
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
dsolanki-initos pushed a commit to initOS/pos that referenced this pull request Apr 16, 2021
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
hitrosol pushed a commit to solusiaglis/pos that referenced this pull request Jun 25, 2021
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
wpichler pushed a commit to Callino/pos that referenced this pull request Nov 19, 2021
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
eLBati pushed a commit to eLBati/pos that referenced this pull request Mar 8, 2022
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
eLBati pushed a commit to eLBati/pos that referenced this pull request Mar 8, 2022
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
OCA-git-bot pushed a commit to eLBati/pos that referenced this pull request Apr 26, 2022
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
dsolanki-initos pushed a commit to initOS/pos that referenced this pull request Aug 8, 2022
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
eLBati pushed a commit to eLBati/pos that referenced this pull request Sep 15, 2022
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
flotho pushed a commit to flotho/pos that referenced this pull request Mar 20, 2023
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
flotho pushed a commit to flotho/pos that referenced this pull request May 5, 2023
* [ADD] pos_loyalty: loyalty programs for POS

* [FIX] Limit to one discount reward per order

* [FIX] Remove unused variables and returns

* [IMP] Refactoring rules loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants