Commit Graph
37 Commits
Author SHA1 Message Date
Christophe Simonis 5ac7557df2 [MERGE] forward port branch saas-11.3 up to a9f3cf76b93 2018-11-16 14:27:04 +01:00
Christophe Simonis 89ed115fe0 [MERGE] forward port branch 11.0 up to d2af0b13250 2018-11-15 20:41:29 +01:00
Christophe Simonis f89eef2b60 [MERGE] forward port branch saas-15 up to a267fcbdf62 2018-11-15 19:20:15 +01:00
Romain Derie 63131c2584 [FIX] sale_coupon: reset no more eligible applied coupon to Valid state
Before this commit:
When a coupon_program's coupon was giving a reward on a SO and then the
recompute was removing that reward (eg the SO did not met the requirements
anymore) the coupon would not be reset and would be lost.

Now:
If a coupon's reward got removed for some reason, the coupon got reset to a
valid state (`new`) so it can be used again.

Step to reproduce:
  - Generate a coupon from a coupon program that needs requirements (eg $300)
  - Add that coupon to a SO that has a total over $300
  - Coupon is set as `used` and the reward is granted
  - Remove some products to set the SO total below $300
  - Recompute coupon, the reward is correctly removed but the coupon is still
    set as `used` so it won't be usable again and is basically lost.

Closes #3062
2018-11-15 15:57:17 +01:00
Romain Derie 231669e332 [FIX] sale_coupon: remove coupon_program reward if req. not met anymore
Before this commit:
If a reward had been given on the SO with a coupon_program code and that the
program had requirements and that these requirements are not met anymore,
recomputing the SO would not remove the reward.

Now:
If the SO does not met the program requirements anymore, we remove the reward

Step to reproduce:
  - Create a coupon_program with quantity or amount requirements (eg: $200)
  - Generate a coupon for that program
  - Add $200 worth of products (matching the program domain) in the SO
  - Add the generated coupon to that SO
  - You should get the reward as you have $200 in the SO
  - Remove some products from the SO to go below $200
  - Recompute coupons, the reward won't be removed

Closes #3062
2018-11-15 15:57:12 +01:00
Romain Derie 5a75d1aeae [FIX] sale_coupon: unvalid next_order programs if needed
Before this commit:
We would never unvalid a `next_order` program (and thus it's generated coupon)

Now:
We also retrieve applied `next_order` programs as we need to check if they are
still valid too

Step to reproduce:
  - Create a program on `next_order` that require $300
  - Add $300 worth of product on a SO
  - Apply program, it will generate a coupon
  - Make the SO total go below $300
  - The generated coupon is still Valid and the client will receive that coupon
    even if it is not supposed to anymore

Closes #3062
2018-11-15 15:57:06 +01:00
Romain Derie e8efcb1bc3 [FIX] sale_coupon: do not deduce reward quantity on current_order
Before this commit:
1. We were checking if the rewards were in the SO even if it was 'next_order'
   program.
2. We were deducing the rewards quantity for 'next_order' program when checking
   if we had enough products to meet the program requirements.

Now:
1. We don't verify if the reward is on the SO if the program is 'next_order'
2. We don't deduce reward quantity when checking if enough products to meet the
   program requirements if the program is 'next_order'

opw-1907211
Closes #3062
2018-11-15 15:56:25 +01:00
Christophe Simonis eb902f8b39 [MERGE] forward port branch saas-11.4 up to 5999fd47c43 2018-10-23 15:18:46 +02:00
Christophe Simonis 9632d38f0a [MERGE] forward port branch 11.0 up to cba39ad6754 2018-10-19 12:27:00 +02:00
Christophe Simonis 879aef37f3 [MERGE] forward port branch saas-15 up to bff8b16f5d9 2018-10-18 17:16:57 +02:00
Goffin Simon 7633f96306 [FIX] sale_coupon: promotion program with fixed amount
Steps to reproduce the bug:

- Create a promotion program P with a fixed amount discount
- Set a customer tax T on the discount product generated for P
- Create a SO with one line
- Apply the promotion program by clicking on "Update promotions"

Bug:

The SO line with the discount product is generated but the tax T was missing.

opw:1888484
2018-10-17 15:24:33 +02:00
Christophe Simonis edaff83894 [FIX] sale_coupon: adapt coupon program rules to new demo data
Oversight of previous forward-port.
2018-10-02 10:40:14 +02:00
Christophe Simonis dbb575179f [MERGE] forward port branch saas-11.4 up to 8faebd0cf52 2018-10-01 20:17:14 +02:00
Christophe Simonis 3fc388c696 [MERGE] forward port branch 11.0 up to 92d7a5210d7 2018-10-01 10:46:29 +02:00
Christophe Simonis cfca60d422 [MERGE] forward port branch saas-15 up to ed3eff1427c 2018-09-28 19:17:34 +02:00
Romain Derie af0e47f42f [FIX] sale_coupon: compute fixed amount as such
Commit 092200073 broke the discount computation for discount of type
fixed_amount. Indeed the appropriate method was not called anymore and such
discount type would be computed as percentage discount with default value of
10% (field default for percentage).

opw-1888484
2018-09-28 18:14:10 +02:00
Christophe Simonis a17ddde9a1 [MERGE] forward port branch 11.0 up to 1e8ab568c1f 2018-09-26 20:02:37 +02:00
Christophe Simonis 6b5aadc7ce [MERGE] forward port branch saas-15 up to c74e1ae51a8
closes odoo/enterprise#2707
2018-09-22 19:41:40 +00:00
Romain Derie 452e906396 [FIX] (website_)sale_coupon: _compute_tax_id with tax on reward line
It should get tax from the SOL and not the SO's product as the tax is applied
on the SOL only (the reward product has no tax by default).
2018-09-13 15:20:40 +02:00
Romain Derie 5ff0b842df [FIX] sale_coupon: delete 'sibling' lines when deleting a reward line
A discount on products with different taxes will result in as many discount
lines as there is different taxes.

Before this commit, removing one of these lines would not do anything else.
Then, recomputing the coupon would regenerate/add back this line.
On e-commerce, it means you would never be able to remove the program by
deleting its reward lines if there are multiple taxes (and so multiple lines)
since it would `recompute_coupon_lines` right away, adding it back directly.

Now, this commit will ensure that removing one of these lines will also remove
the other ones coming from this program on other taxes.
It means removing a regular product will remove it's reward line that will also
now remove the other program's discount line on other taxes and ultimately will
remove the program from the SO since all the program reward lines got removed.
(It won't affect auto applied program since it will be regenerated afterward)

task-1866977
Related to #2224
2018-09-13 15:16:57 +02:00
Romain Derie 453d8ce703 [FIX] sale_coupon: add tests
Previous commit fixed some bugs on `sale_coupon` (#2224).
This commit add some tests to be sure these bugs are fixed and won't appear
again.

task-1866977
Related to #2224
2018-09-13 15:16:57 +02:00
Fabien Pinckaers b62ebab586 [IMP] product: Unify/Clean product demo data
PURPOSE
=======

1. Unified product demo data
2. Less demo: one per use case
3. Demo data for all models

Specification
=============

1. Refactor all the brol in the demo data
2. Adapt the tests to make them green, as some products are
   renamed, removed, created in python instead of as demo data
   ...
2018-07-05 08:59:55 +02:00
Christophe Simonis 8801177bf1 [MERGE] forward port branch saas-11.2 up to dd571e88f7c 2018-04-16 19:56:43 +02:00
Christophe Simonis dc06f0e4bf [MERGE] forward port branch saas-15 up to 7d49f2f192c 2018-03-29 18:47:19 +02:00
Romain Derie 0a565abfad [FIX] sale_coupon(_delivery): correct discount when specific product
Before this commit:
1. With a coupon set on 'specific_product', the discount amount was multiplied
   by the product quantity twice.
   (Introduced by a42c27f which apply discount on the full price by using
   price_total (already multiplied by quantity) over price_unit.
2. With a coupon set on 'cheapest_product', the discount was not discounting taxes.
3. With a coupon set on 'cheapest_product' and `sale_coupon_delivery` installed, it
   would simply crashes and throws an error since `sale.order.line` has no
   `program_id` attribute.

Now:
1. We no longer multiply by the quantity twice;
2. We apply discount on the full price (with taxes);
3. We use correct attribute to avoid crash.

opw-1830986
2018-03-29 13:14:06 +02:00
Christophe Simonis 7b5b3ea96d [MERGE] forward port branch saas-11.2 up to e1a2b299b23 2018-03-23 16:21:58 +01:00
Nicolas Martinelli 08dc1fc268 [FIX] sale_coupon: fix test
Following https://github.com/odoo/odoo/commit/87c09b8ebcea950b628e5c7adfe847b9f8b6c031
the default COA taxes are not used as sale/purchase default taxes.
2018-03-16 08:31:03 +01:00
Christophe Simonis 3e8443b5de [MERGE] forward port branch saas-11.2 up to cd34fda4ba3 2018-03-09 16:27:28 +01:00
Christophe Simonis 11a089969f [FIX] sale_coupon: relative import 2018-03-01 18:50:12 +01:00
Christophe Simonis c5450ca0c0 [MERGE] forward port branch saas-15 up to 9aca5ca19d0 2018-03-01 18:18:16 +01:00
XavierDo 5bb0318ab4 [Imp] product: move uom in a new addon
Adapt enterprise branch to match changes applied in commit 1b64b193f9a6cfd26dee3d723eac968fa4c5000e
2018-02-26 15:14:36 +01:00
Romain Derie c69778fe6f [IMP] sale_coupon, website_sale_coupon: add tests
Commit a42c27f99e0061b7c4f recently fixed some bugs on sale_coupon.
This commit add some tests to be sure theses bugs are fixed and won't appear
again.

This closes #1744
2018-02-23 18:37:20 +01:00
Christophe Simonis 4889fdb135 [MERGE] forward port branch saas-15 up to 6492adc3c4c 2017-06-27 13:45:01 +02:00
Yannick Tivisse 8f6ec58757 [FIX] sale_coupon: Don't update automatic rewards on the fly
Purpose
=======

Currently we are updating the coupon rewards on the fly when creating/modifying/deleting a sales order line.

To avoid multiple searches on res_partners and product to know whether the customer/product is valid on the sale coupon program, we store the applicable customers and products on the program according to the domain defined on it.

This brings 2 issues:
- The customers/products stored on the program are not updated (Was the original spec)
- The checks are numerous and maybe overkill for the given results

Specification
=============

- Don't recompute the reward lines on SO modifications. Add a button to compute the line by hand and make an automatic compute on the SO validation or on the page shop/payment.

- When recomputing the reward lines, make a search on the res_partners and products instead. Now that the action is not triggered so often we can afford to make a search.

- Don't use the fields rule_partners_domain and rule_products_domain. This should be removed in master.

- The field is_public_included is useless now. And we decided to make the coupon available for all the partners if they fit the domain on the program.
2017-06-21 15:55:27 +02:00
xmo-odoo c3ad67cef2 [FIX] implicitly relative imports 2017-04-28 09:07:28 +02:00
Yannick Tivisse 35332ac1e7 [FIX] sale_coupon: Select only customers on coupon programs 2017-01-30 14:37:31 +01:00
pgu-odoo 5260d22c4d [ADD] sale_coupon: introduce coupon mechanism on sales order
Introduces 2 new concepts:

Promotion programs:
===================

Using promotion programs allows you to propose to your customers:
- Promotional offers limited in time or a limited order number.
- Public code printed in advertisements, magasines, etc.
- Specific offers based on a customers group or a product set.
- A combination of the preceeding points.

You may choose to apply the program reward immediately on the sales order or to propose the reward for a next order. In the second case a coupon will be generated at the order confirmation for the customer to use it later.

Coupon programs:
================

Using coupon programs allows you to propose to your customers:
- Free products or discounts if some conditions on products or purchased amount are met.
- Promotional offers limited in time.
- Generate coupons for a customers group.
- Specific offers based on a customers group or a product set.
- A combination of the preceeding points.

A coupon is applied by entering a valid code if the program rules are met and if the reward is already in the order lines.
2016-12-20 14:46:00 +01:00