Commit Graph
137 Commits
Author SHA1 Message Date
Raphael Collet 0a098aceaf [FIX] core: marking and traversing computed fields before modification
This fixes an issue that occurs when marking fields to compute in the
following situation:
 - it occurs before the actual modification,
 - a relational field is marked to compute,
 - the same field is traversed to inverse some dependency.

When the marking occurs after the modification, the traversal of the
field should actually recompute the field.  However, if the marking
occurs before the modification, the inversion of dependencies must be
based on the current value of the field.  This is the case with method
unlink(): we call method modified() to mark the fields that currently
depend on the records to be deleted, and the fields must be computed
only after the deletion!

X-original-commit: cd19c2d93db8911fe42802640ea32e5d87aadeec
2021-01-04 09:16:20 +00:00
Andrea Grazioso (agr-odoo) d947b37767 [FIX] sale_coupon: select correct minimum amount with/without tax rule
Create a promotion program with the "Minimum Purchase Of" right field
left as blank
It won't be taken into account in SO when clicking on 'Promotions'

When the field is left as blank `rule_minimum_amount_tax_inclusion`
value is `False` and thus break the check.

opw-2392546

closes odoo/odoo#63330

X-original-commit: 814cd954944b76fb8a8cb8e4b8da8d17c0eec88c
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
2020-12-14 13:28:46 +00:00
nie bbf860ae97 [FIX] sale_coupon: allow salespeople to use coupons
Steps:
- Have a demo user with "User: Own Documents Only" rights on Sales.
- Connect as admin
- Go to Sales > Products > Coupon Program
- Click one of the programs
- Generate a Coupon
- Reconnect as demo user
- Create a Sales Order
- Apply the generated coupon

Bug:
Access rights restriction on the coupon.

Sorry, you are not allowed to modify documents of type 'Sales Coupon' (sale.coupon). This operation is allowed for the groups:
	- Sales/Administrator - (Operation: write, User: 6)

Explanation:
When applying a coupon to the sales order, it tries to update the coupon's state and link it to the order. This needs to update the coupon record.
This commit also fixes confirming quotations and cancelling sales orders with coupons for salespeople.

opw:2409858

closes odoo/odoo#63239

X-original-commit: 873340ca98b9732132e056c1ca79c614c6255c1c
Signed-off-by: backspac <backspac@users.noreply.github.com>
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-12-11 12:38:12 +00:00
Martin Trigaux 3f13751e9b [I18N] *: export saas-14.1 source terms
Without demo data

closes odoo/odoo#63238

X-original-commit: 4e6683973b1d1ecc67f1312a8ef98b1272e2d5a5
Related: odoo/enterprise#15268
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-12-11 12:30:42 +00:00
Andrea Grazioso (agr-odoo) f345458d75 [FIX] sale_coupon: avoid double consuming of coupon
Create a coupon code
use it in a quote A
cancel the quote A
use it in a quote B
confirm B
go back to quote A
set to quotation
confirm

Result: you used the coupon code twice

opw-2410684

closes odoo/odoo#63067

X-original-commit: 58d82943c58ed50e2cae27b8eb085fc4e54eebaf
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
2020-12-09 09:08:41 +00:00
Thibault Delavallée e3fd1cd91e [MOV][IMP] sale(_coupon), pos_coupon: reorganize qweb / jinja templates used for mailing
PURPOSE

Clean organization of templates in odoo apps: mail.template records in data,
qweb templates (views) used directly in code, notably using post with view.
Purpose is to ease future improvements in posting based on templates.

SPECIFICATIONS

  * move those templates in their own file to ease their discovering and
    maintenance;
  * put them into data (as those are not views even if it contains qweb)
  * guidelines are now :

    -> Qweb templates should be in data/mail_templates.xml;
    -> mail.template records should be in data/mail_template_data.xml;

  * put their declaration in no update when not done if template has no
    technical code or complex dependency on underlying code;
  * move found mail data (mail.message.subtype or mail.activity.type) records
    in a mail_data file that should contain only "core" records linked to mail;

LINKS

Task ID-2375767
COM PR odoo/odoo#61814
ENT PR odoo/enterprise#14775
UPG PR odoo/upgrade#1936
2020-11-25 12:31:09 +00:00
Joseph Caburnay 0f50dd33d0 [FIX] *_coupon: introduce total_order_count as replacement to get_total_order_count()
closes odoo/odoo#40325

Related: odoo/upgrade#1869
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
2020-11-04 10:34:34 +00:00
Joseph Caburnay e9583cccdd [FIX] *_coupon: use get_total_order_count() on checking maximum_use_number 2020-11-04 08:13:15 +00:00
Joseph Caburnay 4d59d3d1f3 [REF][FIX] coupon,sale_coupon: move mail_template_sale_coupon
mail_template_sale_coupon is specific to sale_coupon so we are moving
it back to sale_coupon module. Additionally, we add a way of selecting
a mail template when generating coupons for customers.
2020-11-03 10:48:04 +00:00
Joseph Caburnay 54c42ae836 [ADD] pos_coupon: allow the use of promo and coupon programs in pos 2020-11-03 10:48:03 +00:00
Victor Feyens 7e26237ffe [FIX] sale_coupon: underterministic recordset order
Recenlty, this method was changed to use set instead of recordsets
to improve the performance of the code.

But set have a non deterministic order, which means the order of the
returned programs returned is not the same, modifying the resulting behavior
as some programs cannot be applied together.

To fix this problem, this commit replaces the set by lists
to ensure the returned recordset keeps the same ordering.

Also rename a potentially conflicting variable caused by the same commit.

Finetuning of commit cc1bb9224b3d50897e8f16404ed10bcc04225c60.

closes odoo/odoo#60472

X-original-commit: 6d4da47fff9a809f65912d4132a5fd3ccaa37b90
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-10-21 15:43:32 +00:00
Victor Feyens f5dcbb297d [FIX] sale_coupon: avoid duplicated checks/filters
Avoid filtering/checking the same condition multiple times on the same
records...

This allows to avoid n more fetch of all applicable coupon programs from
the database (because _check_promo_code is called on each program in a loop).

Also apply the date filter directly in SQL:
* The computation of inherited fields (_inherits) by the orm is intrinsically slow.

	The fields rule_date_from and rule_date_to checked in the _filter_on_validity_dates
	python filter are inherited from sale.coupon.program.rule model.

* Filtering recordsets in SQL is faster.

closes odoo/odoo#60292

X-original-commit: 679ebc3381179f6b18364c6f2b4d4f7f34274698
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-10-19 14:49:15 +00:00
Victor FeyensandLoan Sens 4e69372685 [IMP] sale_coupon: diverse perf improvements
* Use set instead of recordset to incrementally join records
* avoid filtered and mapped calls when possible
* use generators correctly
sum([gen]) --> sum(gen)

X-original-commit: d3daa3793b8fbc9308ec0fb8935d6991b834f3a5
Co-authored-by: Loan Sens <lse@odoo.com>
2020-10-19 14:49:15 +00:00
Victor Feyens d7df652b0f [FIX] sale_coupon: perf improvement
_get_applicable_no_code_promo_programs always returns a subset of
_get_applicable_programs ...

We can thus avoid summing the results from the two methods, which
triggered unnecessary operations and resulted in a recordset with
useless duplicates...

Furthermore, as _get_applicable_programs returned recordset is only
used to compare to other recordsets (substraction or comparison),
it doesn't need to be sorted by the model order.  We can thus
safely order the result by id instead, to reduce the query complexity.

X-original-commit: 5d45322cb6abb689dd15566e938fe75318dfdc4d
2020-10-19 14:49:14 +00:00
Victor FeyensandLoan Sens 70295e5c44 [FIX] sale_coupon: reorder costly method to avoid useless operations
When coupon is installed, all cart (SO) updates on the e-commerce go through
the _remove_invalid_lines method.  It has been proved to be a performance
bottleneck on big instances with a lot of coupon programs.

To reduce the performance impact of this method, this commit reorganize it
to avoid unnecessary operations as much as possible.

X-original-commit: 447057cfbe28db760834fba2dfd2c79303825cbc
Co-authored-by: Loan Sens <lse@odoo.com>
2020-10-19 14:49:14 +00:00
Victor Feyens 5468b9bf98 [IMP] sale_coupon: avoid unnecessary filtering of coupon programs
Instead of summing the programs filtered by "current_order" and
"next_order" usage, use all the programs directly.

We can safely assume that the promo_applicability is always set, and if
not, the code later should still behave correctly considering it wasn't
verified in the other methods.

This allows us to avoid two "useless" walkthrough on the coupons applied
on the current sale order.

X-original-commit: cc74ad0108e47654f4a795556f03841319909c67
2020-10-19 14:49:13 +00:00
Victor Feyens f92f361d68 [FIX] sale_coupon: wrong filtering domain
If only one of the two dates rules fields is specified, it won't be considered
when filtering coupon programs, and the program will always be considered valid...

This commit reorder the conditon to correctly consider both fields: rule_date_from
and rule_date_to, even if only one of the two field is set.

X-original-commit: 871a118d2c72f58185cbf822375282b613e67337
2020-10-19 14:49:12 +00:00
Victor Feyens ee99603444 [FIX] sale_coupon: missing company_id check in domain
A check on the company_id field was forgotten in _get_applicable_programs.
To follow the logic of the following method _get_applicable_no_code_promo_program,
this condition is added to the domain, ensuring coupon programs from other
companies cannot be applied to a sales order.

X-original-commit: 559f1e96e17fadad82261eb32a5d02aa5fe91ca9
2020-10-19 14:49:12 +00:00
Romain DerieandSwapnesh Shah 8a22cf8626 [FIX] website_sale_coupon: correctly handle multiwebsite
Steps to reproduce:
- Create an automatic promotional program P for Website 2.
- Place Order for Website 1.
- Promotion is applied.

Fixes https://github.com/odoo/odoo/issues/55121
Closes https://github.com/odoo/odoo/pull/57895

closes odoo/odoo#60151

X-original-commit: 8a5c53bbc771c0895c001a7f7f43591c5cde2ba6
Forward-port-of: https://github.com/odoo/enterprise/pull/13875
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Co-authored-by: Romain Derie <rde@odoo.com>
Co-authored-by: Swapnesh Shah <swapneshshah111@gmail.com>
2020-10-16 08:50:13 +00:00
Achraf (abz) d4d354e3cf [FIX] sale_coupon: promotion program with several identical products
Issue

    - Create promotion program with product_x
    - Create new quotation
    - Add product_x on the first line
    - Add another product_x on the second line
    - Press "Promotions" button

Cause

    The attribut reward_product_qty except singleton but order_line contain more than one element

Solution

    Take the order line with the higher quantity

opw-2350574

closes odoo/odoo#59637

X-original-commit: 30d66b17ea1829e30de176774c7511aab19851a0
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
Signed-off-by: Achraf <macadelic80@users.noreply.github.com>
2020-10-09 12:40:21 +00:00
Martin Trigaux 90d85eb9c5 [I18N] export saas-13.5 source terms
Without demo data

closes odoo/odoo#56869

X-original-commit: 33f251b6489455cd7221f2c62dee0400a69784b8
Related: odoo/enterprise#12836
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-09-01 11:18:00 +00:00
Victor FeyensandAlex Comba e8697f6093 [FIX] sale_coupon: batch confirmation of sales orders
`_send_reward_coupon_mail` is defined as `ensure_one` but is called on
`self` in `action_confirm` which supports multiple records in self, thus
raising a ValueError when confirming multiple sales orders together.

This commit adapts the method to handle multiple records.

FW-Port of odoo/enterprise#12161

closes odoo/odoo#56861

X-original-commit: 99c230c1c167d7369f8003c0219386799f92097d
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
Co-authored-by: Alex Comba <alex.comba@agilebg.com>
2020-09-01 10:44:08 +00:00
Loan (lse) 54c74bb433 [FIX] sale_coupon: Better performance
On instances with a lot of coupons programs, performance issue arise while using eccommerce (adding item in basket ant opening it in particular).
In the client case, he have ~2000 of them.

Opening the basket with 1 product take:
 Before this commit: ~10s
 After this commit: ~2s

( pyflame is available in the ticket attachment )

`_get_valid_products` use the v13 `filtered_domain` method
Average execution time:
  Before change: 0.001 s
  After change: 0.0001 s
=> 10x times gained

The average execution time of `_is_valid_product` is 0.002 s (20 times slower than `_get_valid_products` for the same result).
=> All use of `_is_valid_product` were replaced by `_get_valid_products`

In this commit targeting master, we also completely remove
`_is_valid_product` as it effectively is no longer used and there are no
stable compatibility requirements.

OPW-2323599

closes odoo/odoo#56460

X-original-commit: c3a9738e25dbd773e3ee7c2175e62219346ef764
Signed-off-by: Adrian Torres (adt) <adt@odoo.com>
2020-08-25 08:08:47 +00:00
Goffin Simon 805e4ab5a1 [FIX] sale_coupon: Promotion programms not company specific
Steps to reproduce the bug:

- Create a promotional program P with company A
- Change to company B and create a SO
- Click on Promotion

Bug:

The promotion created in company A was applied to SO created in company B

opw:2303169

closes odoo/odoo#55010

X-original-commit: 3e88c5157ca344208ad4853c529baab732c1c2dd
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2020-07-27 16:36:31 +00:00
Victor Feyens e8893f84ab [IMP] *: translations improvements
Avoid concatenation of translated strings & raw values and/or other 
translated values, and use the new _ API (by providing the formatting 
values to ensure the fallback on the english terms in case of wrong 
translation).

By including the expected values inside the string to translate, we 
ensure that the formatted values are included at the right place in the 
resulting translated text.

This also provides more information on the string to translate to 
the translators, s.t. the chosen terms for the translations can be more 
adapted to the translation context.

closes odoo/odoo#54635

Related: odoo/enterprise#11925
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-07-23 12:13:19 +00:00
Andrea Grazioso (agr-odoo) e482adc179 [FIX] sale_coupon: fix step like programs discount
Create four promotion programs:

if the order > 1500 than 10% discount
if the order > 1750 than 15% discount
if the order > 2000 than 20% discount
if the order > 2500 than 25% discount

Take a product with a price of $300 and add 5 to cart > the 10% discount
is correctly applied.
Add 1 more product (6) > it should now qualify for 15% discount, but it
stays at 10%
Add 1 more product (7) > it (correctly) gets the 20% discount
The 25% discount does not get applied until 11 of the product is in the
cart, even though it should qualify at 9
If you then decrease the quantity, the right discount will
sometimes display.

This occur because when the order amount change and the new total is
used to match the right promo the previously applied discount is not
removed from the amount.
This occur as side effect of
1d59785 in which the amount has to be
kept in order to avoid discount line removal on cart update.

opw-2285656

closes odoo/odoo#54400

X-original-commit: 28c099e6d5b02518b6b5a0be66b2b74a57f0c936
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-07-13 13:18:54 +00:00
Andrea Grazioso (agr-odoo) 1c856c779b [FIX] sale_coupon: fix order total price for reward computation
Create a promotion program with conditions:
- Minimum product quantity (ex 2)
- Minimum purchase in currency (ex 500$ tax excluded)
- Auto apply
- On current order
- with reward:
-- Free product (Free Prod A)
-- 1 Quantity

Create a sale order. Insert 3x ProdA @ 1000$. Click on "promotions".
Nothing will occur because the minimum order amount for applying the reward is
calculated removing from the order the product associated with the
reward. This removed all of the products from the order, so the result is 0.

Fixing by subtracting just the amount specified in the reward program.

opw-2274316

closes odoo/odoo#53407

X-original-commit: 804461fb1353c931986eeae94bd3ad8465b604e7
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-06-22 11:51:30 +00:00
Martin Trigaux 80e97e98ce [IMP] *: use named placeholders in translated message
When more than one parameter is present in a message, it helps the
translation to use named placeholder. This way, the order can be
changed. It also helps the comprehension of the message.
2020-06-18 13:03:34 +02:00
Andrea Grazioso (agr-odoo) 2bb9e779d1 [FW][FIX] sale_coupon: free product quantity in promotion
Create a promotion program with conditions:
- Minimum purchase in currency (ex 100$ tax excluded)
- Auto apply
- On current order
- Unlimited use

And reward:
- Free product
- 1 Quantity

Go to website shop. Fill an order with amount above the minimum
required by the program. The promo will apply and add the free
product.
Increasing the order amount will eventually make the free product
quantity increase, eventually overcoming the reward product
quantity.

Fixing by calculating the reward quantity using both minimum quantity
and minimum amount and using as cap the to reward product quantity
currently in cart

opw-2246138

closes odoo/odoo#51680

X-original-commit: 02331a34cf66117b27cfa1e96078b4721cbd1e70
Related: odoo/enterprise#10722
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-05-22 10:51:47 +00:00
Joseph Caburnay afad149eb8 [REF] *_sale_coupon: create coupon module
This refactoring extracts parts of `sale_coupon` module to create a more
generic module called `coupon`. This new module can be extended in
different sales modules to implement functionalities specific to modules
that extend it.
2020-05-08 14:27:29 +00:00
Joseph Caburnay ef05ca2812 [REF] sale_coupon: rename/move files to prepare coupon module
An initial step to prepare the creation of coupon module. The main goal
is to just move the logic from sale_coupon to coupon. To come up with
less diff as possible, this rename/move step is beneficial for this
purpose.
2020-05-08 14:25:54 +00:00
Andrea Grazioso (agr-odoo) 5e94c70541 [FIX] sale_coupon: fix _remove_invalid_reward_lines check
Create a coupon program with:
- Minimum purchase in currency (ex 100$ tax excluded)
- Fixed discount applied on order (ex 100$)
Generate some coupon.
Go to shop. Fill an order with amount slightly above the minimum
required by the coupon (ex. 125$). Apply the coupon.

Nothing occur to the cart: the coupon is applied correctly,
but when the cart is refreshed it will check for any non-applicable
promotion against the current order state (125$ - 100$ = 25$, since
the coupon check is for orders above 100$ the promotion will be removed).

Fixing the condition in '_get_no_effect_on_threshold_lines' to detect
also coupon lines in order to make the fair computation.

opw-2224169

closes odoo/odoo#50694

X-original-commit: 2f733ba85320dd67c6892f6a56e3680a3b2fbb50
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-05-05 16:14:07 +00:00
Martin Trigaux 2d00263127 [I18N] *: export saas-13.3 translations
closes odoo/odoo#50031

X-original-commit: 15a7a9f9d71a0b9c46d7caf2f4fbf09a5a4c63fe
Related: odoo/enterprise#10140
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-04-23 07:13:48 +00:00
343f9e872f [FIX] sale_coupon: prevent the addition of reward line on copy.
Currently, when there is promotion with usage Automatically Applied
and creating quotation without reward line but on copy of that order
the reward line will be added even the original quote did not have the
reward line(discount).

So in this commit, on copy of the sale order, unlink and apply reward
line only if origin sale order has the reward line.

TaskID: 2228249
OPW-2227968

closes odoo/odoo#49798

X-original-commit: 88aae85cafaeec763a05f49003aff5d593a8922d
Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
Co-authored-by: Mahendra Barad <mba@odoo.com>
Co-authored-by: Rushi Sathawara <rus@odoo.com>
2020-04-20 13:48:11 +00:00
Swapnesh Shah cbd103eafc [FIX] sale_coupon: expected singleton archiving coupon
Before this commit, There was expected singleton tracback on Archiving multiple Coupons at once.
With this commit, We are passing single Record to process.

This is manual Forward port of https://github.com/odoo/enterprise/pull/9637
(Coupons modules went from OE to OC in saas-12.3)

closes odoo/odoo#48996

X-original-commit: d8c2c7269560920511598414741ad42e1f7a0213
Signed-off-by: Romain Derie <rdeodoo@users.noreply.github.com>
2020-04-03 18:41:06 +00:00
Victor Feyens a3ded9043d [IMP] *: declare ir.rule in noupdate
ir.rule are default values but can be customized based on the
company's policy and needs.
This is typically a record that is in noupdate as should be
customization-friendly.
2020-03-20 16:21:25 +01:00
Victor Feyens 532c083cbb [IMP] *: remove global field definition in ir rules xml
It is a computed field, there is no need to manually set its value.
2020-03-20 16:15:40 +01:00
Nicolas Martinelli b91085e5ca [FIX] sale_coupon: validity duration of coupons
- Create a Promotion Program with
  'Applicability' set to 'Apply On Next Order'
  'Promo Code Usage' set to 'Use a code', set a code (not required,
  only for easiness)
- Create a SO, use the code and validate
- In the Promotion Programs, open the coupon list

The Expiration Date is set to tomorrow.

The Expiration Date is not useful in this case, and it is computed only
because the default value of `validity_duration` is 1. However, the user
is not able to change it since `maximum_use_number` is used for
programs instead.

We set a default value to zero to avoid any confusing computation.

opw-2210794

closes odoo/odoo#47779

X-original-commit: 44e71f9192d8711cbaeac0088db55c3ff26813a1
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-03-17 09:59:23 +00:00
Victor Feyens f129dff5a0 [IMP] sale_coupon: no need of sale_management module for sale_coupon
When installing website_sale_coupon, you are forced to install sale_management,
it shouldn't be the case.

Task Id : 2192587

closes odoo/odoo#46416

Related: odoo/upgrade#861
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-03-09 14:33:25 +00:00
Martin Trigaux 0cc8610923 [I18N] export saas-12.3 source terms
closes odoo/odoo#45285

X-original-commit: bb281e98f52a2716f00d43a07446a08df698c1dd
Related: odoo/enterprise#8413
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-02-13 11:45:39 +00:00
mcm-odooandThibault Delavallée de1743ab12 [REF] mail, various: remove user_signature field from mail.template
RATIONALE

Mail template model holds a field telling odoo mail engine to automatically
add the current user's signature to the body. Its use depends on the use
case

  * using the template in the composer on a single record: it is displayed
    in the rendered template in the composer, meaning people could change it.
    This behavior is interesting as it allows to see the email content;
  * using the template in the composer in mass mail mode: it is not displayed
    as only the raw jinja is displayed. It is therefore not obvious that it
    will be appended to the body of the mail. People could add it manually and
    have 2 signatures as a result;

A mechanism automatically adding a signature to sent emails when posting a
message is already implemented and is based on template existence. If a
template has been used when posting, no signature is added in sent emails.
Otherwise it is automatically added. This behavior should not change.

Behavior will therefore be

  * use a template -> specify signature usage in it manually through jinja;
  * do not use a template -> signature added in sent emails;

SPECIFICATIONS

Remove user_signature.

Update template body accordingly. In customer oriented templates that are using
it and do not already contain it, manually add a call to user.signature within
the jinja code. When set to False, just remove its declaration.

Quickly clean some signature integration.

LINKS

Task ID 2089252
Community PR odoo/odoo#39482
Enterprise PR odoo/enterprise#6459
Upgrade PR odoo/upgrate#761

Related: odoo/enterprise#6459
Related: odoo/upgrade#761
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Michaël Mattiello <mcm@odoo.com>
Co-authored-by: Thibault Delavallée <tde@odoo.com>
2020-02-11 14:01:13 +00:00
Victor Feyens a8ecefcd94 [IMP] sale_coupon: batch coupon cancellation. 2020-02-11 09:25:19 +00:00
Yannick Tivisse 65b7d1f1ea [IMP] sale_coupon: Allow helpdesk users to send coupon by email
Purpose
=======

Helpdesk users don't have the right to write on a coupon.

When sending a coupon by email, the coupon is marked as 'sent'.

Allow users to send coupons by executing the state change in sudo.

closes odoo/odoo#45091

Taskid: 2179609
Related: odoo/enterprise#8143
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-02-11 12:49:27 +00:00
Martin Trigaux 65530dfd6a [ADD] *: add ir.model.access on all transient models
Following changes needing ir.model.access on transient models too.
Remove groups declaration on the action to move it to ir.model.access
when possible.
Rules are strict by default with no unlink access by default and high
priviledge asked. Adaptations may be needed later.
Write access is given as a wizard may need to be modified in case the
action triggers an error and the user has to correct a value

account*: use account.group_account_user for all transient by default
	  remove account.print.journal relic
stock*: use stock.group_stock_user by default
survey: survey user can send invitations
mail: allow any employee to execute wizards
      additional verifications are made to ensure they are executed
      only on the documents the user has access to you
      give portal access to mail.compose.message as portal still does
      some actions like posting messages on the forum
      add ir.rule to avoid reading somebody else messages
      increase the query count because of undeterminist count
crm: saleman for lead2opp, manager for massmailing
     partner manager for actions linked to partners
     avoid a write in test_lead_lost
sms: any employee can send sms
mrp: mrp user can execute wizards
     give unlink access as making write during do_produce operation
base_import: employees can import files
delivery: stock user can deliver
event_sale: sale user can configure the wizards
	    event user inherit from  sale rights
gamification: employee can give badge
google_service: resolve FIXME
hr: add specific rights
    manager can set a plan according to group on button
    anyone who can write on an employee can register a departure
hr_expense: set rights based on buttons
hr_holidays: an approver can make a summary report
hr_recruitment: recruiter can refuse a candidate
hr_timesheet: can use the wizard if can create a timesheet
l10n_eu_service: managers can create fiscal positions
mass_mailing: same group as on mass.mailing.list
membership: accountant can create invoice from membership
payment: accountant can create a link
	 as the source is an account.move
	 keep the payment.acquirer.onboarding.wizard to system user
	 only as it is called during company configuration
point_of_sale: PoS manager only can use wizards
	       never create closing_balance_confirm_wizard records
product_expiry: stock user has rights on stock.picking
product_margin: access from accounting menus
repair: same rules as for above models
sale: set ir.rule for self wizard only
      add rule from model introduced in payment to add salesman group
sale_crm: saleman can create a quotation from a lead
sale_coupon: any saleman can generate coupon
	     add self ir.rule
sale_product_configurator: salesman can select product variants
snailmail: employee can send letters
website: designers can write on website
website_crm_partner_assign: same rule as group on action
website_sale: sale ACL as for payment.acquirer.onboarding.wizard
website_slides: anyone can send invitation

base: base.language.*: allow employee (cf lang_install)
      change.password.user: can not read change password wizard of
      other users
      test.*: no access is needed

Courtesy of Damien Bouvy, William Andre and Antoine Prieëls for review
of acl
2020-02-04 17:54:18 +01:00
mgh-odoo d25fac7e8d [IMP] sale_coupon: coupon pdf design
as per the task requirements pdf coupon design changed
same as email design.

Task-ID: 2027296
Closes #34620

Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
2020-01-31 12:46:17 +00:00
mgh-odoo bb87d3f674 [IMP] sale_coupon: refactor the coupon stages and usability improvement
Fix the layout of logo to the printed coupon.

The traceability of the coupons is not clear. for Ex. coupon is send or not?
should I resend? so updated the stages of the coupon

Now the stages will be like
 -pending(previously reserved) -- hidden by default
 -Valid
 -Sent : updated when mail is sent to customer
 -used
 -expired
 -cancelled : hidden by default(added button to cancel the new coupon)

Cron added to expire coupon automatically.

PS: model sale.coupon do not inherit the thread so instead of message_post
change the state 'sent' from mail_compose_message.

Task-ID: 2027296
Closes #34620
2020-01-31 12:46:17 +00:00
mgh-odoo c2775164ab [IMP] sale_coupon: coupon layout and usability improve
some layout fixed and confusing string of promo_applicability option is
changed to 'Send a Coupon' form 'Apply On Next Order'.

Task-ID: 2027296
Closes #34620
2020-01-31 11:11:56 +00:00
Martin Trigaux a74a648030 [IMP] *: use ast.literal_eval
When simply need to parse a domain, it is easier

Add .strip() on ir.ui.view as ast.literal_eval produces an syntax
error if the node starts with spaces (as done in the xpath of
hr_attendance.view_employee_form_inherit_hr_attendance)

closes odoo/odoo#43831

Related: odoo/enterprise#7894
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-01-28 13:58:05 +00:00
Victor Feyens d0bcf89c33 [IMP] *: remove 'remove me in master' 2020-01-21 14:43:29 +00:00
Romain Derie 98678199a3 [FIX] *: fix translations inconsistency in 't-set'
This commit fix most `t-set` errors that either led to:
  1. unwanted text to be considered as translatable.
     eg: `<t t-set="classes">text-left bg-100 p4</t>` would create an
     `ir.translation`.
  2. text that should be translatable were not.
     eg: `<t t-set="text" t-value="'Both'"/>` would not create an
     `ir.translation` while it should.

If a text should be translatable, it should never be inside a `t-value`:
  - `<t t-set="text">Both</t>`
If a text should not be translatable, it sould either be inside `t-value`,
`t-valuef` or the `<t>` tag should have `t-translation="off"`:
  - `<t t-set="classes" t-translation="off">text-left bg-100 p4</t>`
  - `<t t-set="classes" t-valuef="text-left bg-100 p4"/>`
  - `<t t-set="classes" t-value="'text-left bg-100 p4'"/>`

https://github.com/odoo/odoo/pull/43660
https://github.com/odoo/enterprise/pull/7839
https://github.com/odoo/design-themes/pull/203

closes odoo/odoo#43660

Related: odoo/enterprise#7839
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2020-01-21 15:32:08 +00:00