100 Commits
Author SHA1 Message Date
Victor Feyens 27ef7d571b [FIX] account,purchase,sale: wrong mail thread method signature
Since 3eb9680602, the signature of method
`_notify_by_email_prepare_rendering_context` has been changed to provide
a default values to `msg_vals` and some overrides were not adapted
(or have been added afterwards).

No true bug/issue has been found caused by that discrepancy, but for
consistency, this commit makes sure those overrides are adapted to
provide the same API as the parent method.

Fixes #162742

closes odoo/odoo#163418

X-original-commit: d4b31842d6c3e1c5c86d9019a353601914ebf1f7
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-04-26 10:05:20 +00:00
Victor Feyens 9338ac0174 [FIX] website_sale: harmonize tax computation
Standard `sale` tax flows rely on `_get_tax_included_price_unit`,
whereas part of `website_sale` flows do, while another part relies
on `_fix_tax_included_price_company`, which doesn't handle some
advanced cases (fiscal position mapping of price_included taxes).

This commit drops the use of `_fix_tax_included_price_company` in
website_sale, to only use the newest API of `_get_tax_included_price_unit`,
supposed to handle more cases.

Also makes all taxes computation go through a single entry point,
`_apply_taxes_to_price`, already used for `combination_info` logic (/shop/product),
but not in `_get_sales_prices` (/shop page).

opw-3700803

original commit : 662ea281515156a781ab68079d0123ea45ebf40f

closes odoo/odoo#160198

Signed-off-by: Laurent Smet (las) <las@odoo.com>
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-04-02 18:17:59 +00:00
Victor Feyens b6688b1a47 [IMP] account: split _get_tax_included_unit_price_from_price util
separate the true computation of the tax value from the computation of the base unit price (uom & curr conversion, ...).

That way, the risks of unwanted side-effects is reduced when the base unit price is already computed (sale, website_sale).

Also allows preprocessing the taxes mapping, which doesn't have to be done multiple times when we compute different amounts for the same product/template.

original commit: bc79770d1e00cf86a46002d633afd8b32921610b

Part-of: odoo/odoo#160198
2024-04-02 18:17:59 +00:00
Victor Feyens 7cddd35acd [FIX] website_sale: non deterministic test failures
Wild try to avoid failures on runbot builds (not reproducible locally).

* simplify and split tour steps
* correctly specify check steps as isCheck: true
* make sure python setup is deterministic
  * batch template creation to avoid creation of dummy archived variant
  * target values for the variant to archive instead of its number in the
  list of variants

runbot build error 25046

closes odoo/odoo#159372

X-original-commit: 9906785faf81d3152a94942f8e25827d2234db29
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-03-28 12:19:08 +00:00
Victor Feyens dc7b75f9fb [FIX] sale: forbid pricelist changes on confirmed orders
It cannot happen through the default SO form view, but some funny guys
have found other ways to do it, even though it can be quite problematic,
especially if the new pricelist is in another currency.

closes odoo/odoo#157742

Related: odoo/enterprise#58744
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-03-28 12:19:05 +00:00
Victor Feyens 458ccf74eb [FIX] delivery: revert method signature change
36e6728b2cac87c7cd922001be0222688ad52abb fixed an issue
where the volume and weight were incorrectly computed
for carriers based on rules.

But it was done by changing the method api, which
seems to break some custom modules using/extending
the modified methods.

This commit reverts the API change, conveying the
needed information through the context for now
(the api change will be done in master only).

opw-3826165

closes odoo/odoo#159220

X-original-commit: d6e004b23822e98e8d1052b75b66a7d4f6d2c38c
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-03-26 09:54:31 +00:00
Victor Feyens 9e029c6710 [FIX] website_sale: product autocomplete with tags
Steps to reproduce:

* Create a product tag (available on ecommerce)
* Select that filter on the /shop page
* Enter a search string

-> Traceback

The selected tag is given as a string to the
autocomplete route, and not a list of ids,
which fails when converted to an 'in' domain leaf.

`[('product_variant_ids.all_product_tag_ids', 'in', tags)]`

This commit makes sure to convert the given ids to a
list, correctly handled by the orm.

Fixes #155327

closes odoo/odoo#155430

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-03-19 11:14:03 +00:00
Victor Feyens 3c2a420851 [IMP] sale: discount should not be recomputed on confirmation
Add test to cover a problem fixed in `sale_subscription`

opw-3740645

closes odoo/odoo#157699

Related: odoo/enterprise#58673
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-03-15 01:04:09 +00:00
Victor FeyensandAaron Bohy 6a83ace2b1 [FIX] web: x2many field with empty changes
In some conditions, a x2many field can be considered
as modified by the webclient when in fact there is
no change in 'meaningful' stored fields.

In this case, on save, an empty list of magic commands
will be sent to the server, potentially triggering
unexpected recomputations.

Steps to reproduce:

* install sale_stock & sale_management
* create a new storable product
* create a new SO
* create a new line with this product
* Confirm the SO
* Set or Update the SO delivery date (Other info tab)
* Save

-> In the chatter, you will notice an useless tracking
value being printed for the SO Total, with identical values
before and after update.

Cause

Since the server received an empty list of commands for
the `order_line` field, this triggered a recomputation
of the total amounts of the SO, even though there were no
effective changes in the lines.

Solution

Do not send empty command lists for x2m fields.
This will avoid unexpected recomputation and also improve
performance since the fields were recomputed for 'nothing'

closes odoo/odoo#155549

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
2024-03-05 16:48:16 +00:00
Victor Feyens 463d21787c [REV] sale: avoid prices recomputation
This reverts commit 789186a43c.
The fix is not necessary in 17+ since the new onchange only
sends the necessary information and not the whole x2m record
data.

closes odoo/odoo#155550

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-02-27 14:41:48 +00:00
Victor Feyens 789186a43c [FIX] sale: avoid prices recomputation
Steps to reproduce

* Create a new SO
* Add a new line with a storable product and 15.12 as quantity
* change the price to X
* Save and confirm
* Set a scheduled date (Other info tab)
* Save

-> The price of the SOL is recomputed.

Cause

Because of floating point issues, the value returned by the onchange for
the product_uom_qty field is 15.1200000....1, therefore being considered
in the client-side as having been changed by the onchange.
The value is then sent to the server on save, triggering a recomputation
of the SOL prices.

Until there is a clear solution in the framework, this commit drops
'unmodified values' for the product_uom_qty field, only if there is
one updated line in the write call.

opw-3670318

closes odoo/odoo#155392

X-original-commit: ef1b59062266ee4ab58b5330ce0012dcee69f2b7
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-02-26 23:09:36 +00:00
Victor Feyens 11ba706626 [FIX] sale_product_configurator: custom attributes update
Updates to existing product configurations with custom attributes
were not correctly applied on configurator closure.

This was probably caused by a recent update in the framework.
Nevertheless, to solve the problem, this commit drops the use
of custom code used only by the configurator to stick to the
standard usage of magic commands.

closes odoo/odoo#152934

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-02-19 15:02:20 +00:00
Victor Feyens 787bebf302 [FIX] sale: hide cancel button on locked orders
You have to unlock the order before cancelling it.
Introduced by 17bece3e79

Fixes #153987

closes odoo/odoo#154259

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-02-15 19:47:05 +00:00
Victor Feyens 5bcb3e0cf6 [FIX] payment(_custom): provider uninstall
Since fd2fb212c5, the
sepa provider (enterprise module) behaves as a custom
provider but despite some adaptations, the removal
of providers on module uninstall was not properly
adapted.

The uninstall of the sepa provider failed as its
inline template was not unlinked from the provider
before the template deletion.

This commit makes sure that custom providers are
correctly considered in the uninstall util supposed
to restore a provider to its state before the
installation of its module.

opw-3734697
opw-3721846

closes odoo/odoo#153843

X-original-commit: e70dbbae56472b124a59c38a1fbfeea23c8ec28b
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-02-13 17:59:58 +00:00
Victor Feyens 673f064cba [IMP] product: do not search items if no pricelist
Rules always have a pricelist, so we can avoid an
useless database query when we are computing the
prices without any pricelist.

Also makes sure that the modified context used
for the pricelist items search is not propagated
by enforcing the same context in the returned
rules.

closes odoo/odoo#153624

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-02-13 10:07:58 +00:00
Victor Feyens 3d8be5aa4c [FIX] website_sale: consistent tax computation
While fixing a non deterministic test failing
on nightly l10n builds, slight incoherences between
sale & website_sale tax computation have been noticed
in the computation of the contextual price (used in
some snippets).

This commit fixes the test, making sure it doesn't fail on
l10n builds, but also uses the same tax util in website_sale
than in sale, to make sure the displayed amounts are coherent
(and supposedly correct).

runbot error: 52831 (& a bunch of others)

closes odoo/odoo#153299

X-original-commit: 91f9057c73810c34a4b0b85a60c84bb1c482efa4
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-02-13 10:07:53 +00:00
Victor Feyens 3f6decab83 [FIX] sale: do not lose currency rate precision
Since 857c485175, rates are
not truncated anymore.

The stored rate value on SO, between SO currency and company currency
was not adapted and was still truncated, leading to invalid values
after rates conversion.

See also 5a621cea4c5a16998a3b83890144f81a3880244b where the same solution
was appied to pos orders.

opw-3638199

closes odoo/odoo#152592

X-original-commit: 6291424bd49a55f446f87c09af71fd13a1c13851
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-02-05 11:00:15 +00:00
Victor Feyens 7931603513 [FIX] sale: sales analysis discount
Summing discount percentages doesn't mean
anything.

This commit makes sure the operator used to
compute discount on group of records is 'average'.

It won't always be meaningful, but in some cases,
e.g. when the solines only hold one product,
and the lines are grouped by product.

opw-3649377

closes odoo/odoo#152455

X-original-commit: bf4aa3fdfcb6b2b3a5b4411130321e154fa098aa
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-02-03 06:59:48 +00:00
Victor Feyens db62d96faf [FIX] sale: wrong invoicing address on portal
The address displayed as 'Invoicing address' was
the main SO address and not the invoicing one.

Also, the pencil icon link to update the customer main address
was always displayed next to the invoicing address, even if:

* the so does not belong to the customer
* the invoicing address is different than the
customer main address

This commit fixes those two issues.

opw-3653190

closes odoo/odoo#152298

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-02-02 19:49:39 +00:00
Victor Feyens 9ea17019f6 [FIX] core: default multi-company domain
of check_company=True fields.

Suppose two models

class A:

    company_id = fields.M2O() # not required

class B:
    _check_company_auto = True

    company_id = fields.M2O() # not required
    a_id = fields.M20(check_company=True)

and the following code:

a = A.create({'company_id': 1})
b = B.create({'a_id': a.id, 'company_id': False})

The creation of B will fail because of the multi-company
checks, which is expected.

Nevertheless, since 0d30cc2bc9, the domain
of the field a_id would be:

(company_id and ['|', ('company_id', '=', False), ('company_id', 'in', [company_id])] or []) + ([])

which means that through the interface, if you create a record b following
the example above (no company_id on b), the evaluated domain would be empty,
allowing to select records of class A, even if they belong to another company.
Of course, this would lead to a multi-company error when trying to save the
record.

This commit makes sure that the right domain is applied on
check_company=True fields, even if the current record has no value
in its `company_id` field.

opw-3629374

closes odoo/odoo#151341

X-original-commit: aaddedc3bab4f16747fb0f71ae626d94f3975ee3
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-01-27 00:01:24 +00:00
Victor Feyens 330f427367 [FIX] website_sale: displayed discount on cart
Since 17.0 , calls to _get_combination_info on the
/shop/cart page were removed to avoid recomputing
values already stored on the cart, speeding up
the page loading.

See 824fc94bbc

Nevertheless, this highlighted the difference
in pricelist discount computation between sale
and website_sale.

In sale, the discount is computed while considering
the base price of the pricelist, whereas for
website_sale, the base price was always the sales price.

To make sure the crossed price displayed is the sales
price as before on /shop/cart, we override the default
sale behavior to force the sales price to be considered
as price before the pricelist discount.

closes odoo/odoo#151321

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-01-26 19:26:16 +00:00
Victor Feyens 29a8093b16 [FIX] delivery,website_sale: do not make api request on page rendering
Following a fix in 16.3 with 5052b9e4a15155c694cf005fdf330997770c6cac,
backported in 16.0+ with commit d28a8f67da06e58358b40636d1dca1f91a84e1ad,
the rates for the different carriers were computed on page loading,
to make sure unavailable carriers were hidden.

Nevertheless, this leads to significant increases of /shop/payment page
loading time depending on the enabled carriers.

This commit restricts the previous fix to the targeted type of carriers,
aka `base_on_rule` ones, whose rates do not depend on third party API
requests.

closes odoo/odoo#149657

X-original-commit: 99c8bda43f6f3bb027f8e03a753aaf2bb7ac585f
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-01-18 12:01:04 +00:00
Victor Feyens 6d99cf3eb6 [FIX] sale: access error on first pending payment
Steps to reproduce:

1) Install and enable the "Onsite" payment provider;
2) As a public user, add product(s) to your cart;
3) Try to pay with the "Onsite" provider.

-> Internal Server Error

Cause of the issue:

In the log, the cause of the issue is an AccessError,
specifying that we tried to read the field `transaction_ids`
on a `sale.order` without having the necessary access rights.

This shouldn't happen, since the payment & ecommerce flows
are executed in sudo mode, after making sure that the cart
belongs to the customer.

After investigation, pending payment transactions trigger
1) the sending of a mail to the customer
2) the first mail generation will request the report assets
3) the generation of the report assets will create an
   attachment and commit the transaction
4) committing the transaction will trigger a global
   flush of the environment, forcing the computation
   of pending mail wizard fields, with a different
   environment than the sudoed one initiating the sending
   of the mail.

This will lead to security errors as we try to access
`sale.order` fields content without having the rights
for it.

Standard fields being already in the cache, it will
be noticed when trying to read the `transaction_ids`
field.

Solution:

Manually prefetch the `transaction_ids` content with
the sudoed environment, since the records cache is
shared between the environments (until a more global
fix is found and deployed).

Introduced by #121376

opw-3628753

closes odoo/odoo#148199

X-original-commit: 511fe642b9860bd9d2f6b7ed728e7d3e6af48748
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-01-05 10:34:45 +00:00
Victor Feyens 0753deb2ba [FIX] website_sale: missing translation
closes odoo/odoo#145903

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-12-12 23:08:53 +00:00
Victor Feyens 070e78a726 [PERF] website_sale_wishlist: check wishlist content once
For each product of the shop page (if the template was enabled ofc),
a call to `_is_in_wishlist` would be made, triggering one query to find
the wishlist belonging to the current customer.

This is now done only once in the controller to load all the wishlisted
products.

This code was previously taking up to 15% of the loading time, even when
no wishlist were ever created on the database.
Now, in the best case (no wishlist, standard situation), the time taken
went down to 0.05% of the loading time, gaining > 100 ms of loading time
(when website_sale_wishlist is installed and the template is not disabled).

closes odoo/odoo#142860

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-11-28 21:20:56 +00:00
Victor Feyens 29b6b851a6 [PERF] website_sale: cache attributes display
After profiling and investigation of /shop route flamegraphs,
we have noticed that the rendering of attributes filters
is taking up to 70% of the loading time.

Since attributes are a not so frequently modified and do not depend on
any other contextual data, this part of the template can be easily
cached to improve loading time.

Part-of: odoo/odoo#142860
2023-11-28 21:20:56 +00:00
Victor Feyens 540872d86b [FIX] website_sale: invalid cache
product prices are dependent of so many factors (taxes, pricelist, fiscal position, ...)
that caching them is either wrong or unproductive (because of the complexity of the cache to manage).

This commit removes this specific cache.
A dedicated performance review is done in the same PR to make sure
the performance is optimized as much as possible.

Part-of: odoo/odoo#142860
2023-11-28 21:20:56 +00:00
Victor Feyens 4f582eee86 [PERF] website_sale: do not load all the product tags
Checking on the searched products whether they have tags (through the field) before searching
for them is highly inefficient, will fill the orm records cache for "nothing",
and will be executed in slow, separate queries, highly slowing down the /shop
page loading time.

Part-of: odoo/odoo#142860
2023-11-28 21:20:56 +00:00
Victor Feyens fe82085f22 [FIX] sale: do not track quantity change if product changed too
Customer should do it in two steps if that's really what they want to do.
This custom log was mainly intended to follow quantity changes on confirmed
orders, but it's plain wrong if the product is changed at the same time.

opw-3432715

closes odoo/odoo#142610

X-original-commit: dd526d049be27ac4852ac0eeaca04c3a2a36c39b
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-11-21 09:21:16 +00:00
Victor Feyens 3a870ad17a [FIX] product: wrong decimal accuracy for pricelist prices
closes odoo/odoo#141716

X-original-commit: 4ecb41c5f0fd15017ed837e9965ee8c84c77edee
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-11-16 11:44:53 +00:00
Victor Feyens bd07557b16 [FIX] website_sale: overlapping x in cart alert
Bootstrap already adds a X on btn-close buttons automatically

Part-of: odoo/odoo#139332
2023-11-14 13:49:16 +00:00
Victor Feyens eb4d6ad0b6 [FIX] website_sale: address updates
Added test for recent fix 495a5090a5
Also fixes a wrong recordset vs id comparison

closes odoo/odoo#141496

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-11-08 05:31:12 +00:00
Victor Feyens 844dbbca4f [FIX] sale: invoices not displayed on SO portal
task-3584770

closes odoo/odoo#141276

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-11-06 16:55:48 +00:00
Victor Feyens 7a02a6a81e [IMP] core: docstring improvements
* clean and improve docstrings in orm
* fix typos found with codespell
* rely on the Environment class docstring instead of doc content (and
therefore move part of the doc inside the class docstring)

closes odoo/odoo#102969

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-07 09:36:23 +00:00
Victor Feyens 8ce3291eaf [IMP] core: docstring improvements
* clean and improve docstrings in orm
* fix typos found with codespell
* rely on the Environment class docstring instead of doc content (and
therefore move part of the doc inside the class docstring)

closes odoo/odoo#102969

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-09 17:56:35 +00:00
Victor Feyens 24c8ff9b28 [FIX] website_sale: address updates
Improved header (billing/shipping address instead of 'my details')
Keep the use_same input value on invalid form refresh

closes odoo/odoo#139474

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-10-24 13:55:25 +00:00
Victor Feyens 7a1f505e31 [FIX] website_sale: do not request shipping address when already given
* if customer said to use the same address as shipping
* if customer already chose/has/gave shipping address

Part-of: odoo/odoo#139474
2023-10-24 13:55:25 +00:00
Victor Feyens e18f6b8f5a [FIX] website_sale: clear empty ecommerce description
Part-of: odoo/odoo#139474
2023-10-24 13:55:25 +00:00
Victor Feyens 880e68b39a [IMP] website_sale: only require phone for shipping addresses
Address form forced the input of phone fields.

1) It only makes sense for shipping addresses by default, for delivery purposes
2) It was not properly handled in global checks, so you could do the whole
checkout flow without having a phone set on your address, but if you went to
the address page, you wouldn't be able to save as your phone would be invalid.

Side-change: do not check shipping address validity for orders without delivery
(only services).

closes odoo/odoo#138026

Related: odoo/upgrade#5248
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-10-20 20:52:42 +00:00
Victor Feyens bce00af708 [IMP] website_sale: address updates
* Avoid posting crappy forms when a redirection does the job
* use a dedicated route /shop/cart/update_address for address changes
* clean code from recent PR on invoicing address
* Public user shouldn't be able to create billing addresses
* Logged customer should always see his own partner as billing/shipping
address choices.

Part-of: odoo/odoo#138026
2023-10-20 20:52:42 +00:00
Victor Feyens 25177023a2 [REV] sale: forbid payment term change on confirmed SO
This reverts commit b1427153f8.

It seems that salesman likes to change payment terms on SO after the confirmation.

task-3562396

closes odoo/odoo#139258

X-original-commit: f83afeffeb30496ad55f901a529144db47942787
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-10-20 11:22:18 +00:00
Victor FeyensandMorgane Demesmaeker 6d1a78286a [ADD] sale_pdf_quote_builder:
When enable, this new feature adds the possibility to set a PDF header, footer and some product
documents to the quotation report.

These PDF can contains forms that'll then be filled using Odoo database.

This replace the previous sale quotation builder feature.

task-3249142

closes odoo/odoo#133773

Related: odoo/upgrade#5168
Related: odoo/documentation#5863
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
Co-authored-by: Victor Feyens <vfe@odoo.com>
Co-authored-by: Morgane Demesmaeker <edm@odoo.com>
2023-10-03 19:19:57 +00:00
Victor FeyensandMorgane Demesmaeker 693b62f38e [REM] sale_quotation_builder
The value provided by the sale quotation builder feature is small due to many problems, and the
technical debt behind is high. For instance:

- The feature is nice but hidden: not visible on quotation, the most visible part is the button
"Design Template" on the quotation template (if you did activate the feature), it requires to have
eCommerce installed...

- The feature  relies on fields that are shared with eCommerce which leads to unwanted behavior:
e.g. updating the bottom of the product page in eCommerce will impact quotation html description on
the portal

- The feature works as template but it is unclear for users: updating the HTML description on a
specific quotation will only impact that quotation. Updating the HTML page of a quotation only
update this quotation

- The feature is technically complex

As we want to keep most of the value of the feature but reduce its complexity, we remove the
quotation builder feature that'll get replace with the PDF quote builder feature.

task-3249142

Part-of: odoo/odoo#133773
Co-authored-by: Victor Feyens <vfe@odoo.com>
Co-authored-by: Morgane Demesmaeker <edm@odoo.com>
2023-10-03 19:19:57 +00:00
Victor Feyens 1d85516d8b [FIX] web: empty filename on binary file deletion
the filename field shouldn't be 'false' but an empty string when
the binary file is deleted.

closes odoo/odoo#135894

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-09-21 18:27:47 +00:00
Victor Feyens 087ff42e3a [IMP] product: stricter documents creation
Do not allow modifying documents types, correctly mark necessary fields
as required, ...

Part-of: odoo/odoo#135894
2023-09-21 18:27:47 +00:00
Victor Feyens 83ab6a87d2 [FIX] sale: new field help
Part-of: odoo/odoo#135894
2023-09-21 18:27:47 +00:00
Victor Feyens cec9dbc8ab [FIX] product: simplify documents list view
Part-of: odoo/odoo#135894
2023-09-21 18:27:47 +00:00
Victor Feyens 6af88b3b6a [FIX] product: documents creation & deletion
1) fix automatic creation of documents when attachments are added
to product templates/variants chatters

2) fix duplication of documents

3) fix deletion of documents

Delete child record before deleting parent record.
Before this commit, when trying to delete a product document,
we deleted the parent record first, before trying to delete
the child, which had been deleted (cascade) already.

Part-of: odoo/odoo#135894
2023-09-21 18:27:47 +00:00
Victor Feyens 0e38237c60 [IMP] sale: avoid 'extra line with down payment' messages
Use a clean message with the downpayment ref directly in the wizard.

closes odoo/odoo#124297

Related: odoo/upgrade#5133
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-09-21 16:52:03 +00:00
Victor Feyens 90796edd15 [FIX] website_sale: do not show unavailable carriers
Carriers with no/invalid/incompatible rules shouldn't
be displayed in the checkout process.

opw-3413820

closes odoo/odoo#135717

X-original-commit: 5052b9e4a15155c694cf005fdf330997770c6cac
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-09-18 10:14:11 +00:00
Victor Feyens bfbf9035d6 [CLN] website_sale: product_template.py
* clean fields definition
* partial methods reordering according to guidelines

closes odoo/odoo#126637

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-09-18 10:13:59 +00:00
Victor Feyens a8366a67da [IMP] website_sale: rely on line info instead of combination
Part-of: odoo/odoo#121986
2023-09-14 18:09:48 +00:00
Victor Feyens 63f0d1cb5a [IMP] sale: harmonize fpos & pricelist request cache
Cache the fiscal position by request the same way it was
done for the pricelist, on the current website record.

Also clean and clarify the pricelist cache at the same time,
making sure invalidations are correctly handled, and that the
whole code relies on the unique logic (& field).

Part-of: odoo/odoo#121986
2023-09-14 18:09:48 +00:00
Victor Feyens 07517d79fa [CLN] website_sale: split product_attribute.py
Part-of: odoo/odoo#121986
2023-09-14 18:09:48 +00:00
Victor Feyens f71cd64567 [FIX] website_sale: correctly update prices according to fiscal position
The prices displayed on the /shop page were not refreshed if the fiscal
position computed for the current partner was modified.

Part-of: odoo/odoo#121986
2023-09-14 18:09:48 +00:00
Victor Feyens ab16589d6c [CLN] sale: product_template.py
Remove unused field
Clean code

Part-of: odoo/odoo#121986
2023-09-14 18:09:48 +00:00
Victor Feyens 6c940679c9 [REM] product: unused company fallback logic
This method & logic is not used nor necessary anymore with
the multi-company fixes and improvements done in the recent years.
* All requests coming from website are automatically done in the website
company.
* check_company restrictions forbid the use of records from different companies
* multi-company security rules restrict the access to records from the current
company.

Part-of: odoo/odoo#121986
2023-09-14 18:09:48 +00:00
Victor Feyens ae7d23ef2e [CLN] website_sale,*: unnecessary pricelist context
There is no need to manually add the pricelist context for ecommerce
flows anymore, it is automatically managed in `_get_contextual_pricelist`
override of website_sale.

Part-of: odoo/odoo#121986
2023-09-14 18:09:48 +00:00
Victor Feyens 4069158c96 [REF] sale,*: combination_info logic
Clean all code related to _get_combination_info:

* Move logic to website_sale now that backend configurator doesn't
rely on it anymore. Only frontend configurator uses that logic.
* Make sure the returned information is correct and consistent:
  * request must be given the right context (multi-company)
  * behavior is coherent between modules and overrides (date, company, currency, rounding)
* Performance:
  * Avoid loading unnecessary information
  * Avoid calling _get_combination_info when only part of the data is necessary.
  * Clean/simplify uses and overrides by keeping useful information in the combination_info dict (taxes, currency, ...)
* Code cleanup
  * clean imports
  * clean architecture
  * clean templates
  * move old configurator code to website_sale

Now that the product configurator backend side has been redone
completely, the remaining parts previously shared between backend
and frontend configurators can be moved to website_sale because only
used by the frontend configurator.

Part-of: odoo/odoo#121986
2023-09-14 18:09:48 +00:00
Victor Feyens 23d2c5294a [FIX] product: automatic generation of documents for attachments
Finetuning of #132739

closes odoo/odoo#134364

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-09-06 05:53:51 +00:00
Victor Feyens 5a801bc602 [ADD] product,(website_)sale: product documents
Introduce new model of "Product Documents" to hold documents linked
to a given product template/variant, displayed on:

* quotations
* confirmed sale orders
* e-commerce product page

This will also replace the previous "Digital Files" (website_sale_digital)
logic & module, which allowed to specify product documents available
to customers after the SO invoice was paid.

This exact feature will be lost after upgrade, since we only keep the
choice to link documents on quotations/orders, but:

1) on e-commerce, carts are supposed paid when confirmed
2) on portal, the "Online Payment" settings makes sure the users
have to pay to confirm their quotation.

therefore we consider new configuration sufficient, without needing
a "paid order" choice as well.

task-3249201

Part-of: odoo/odoo#132739
2023-09-05 10:59:17 +00:00
Victor Feyens 9ed1dc5cae [REM] website_sale_digital
Part-of: odoo/odoo#132739
2023-09-05 10:59:17 +00:00
Victor Feyens 4ddcc2bb4f [IMP] website_sale: method to assess if cart is ready to proceed
Part-of: odoo/odoo#117379
2023-08-31 16:05:44 +00:00
Victor Feyens 028d5b1856 [IMP] sale: add menu to access product categories
Since the new product catalog provides filtering by product categories, and the pricelist rules have long been configurable by product categories, it makes sense to allow users to configure categories directly in the sales application.

closes odoo/odoo#133063

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-24 22:00:06 +02:00
Victor Feyens 484210c5d3 [IMP] sale: ease catalog inheritance
closes odoo/odoo#132341

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-24 18:37:29 +02:00
Victor Feyens 2136b32b95 [FIX] uom: do not allow uom.uom creation from tree view
Since 6f182eeeab,
UoM should be created through the UoM category tab as the UoM form view is now unusable.

Previous bugfix commit 58a3954d606d48b2a4cf678eb0bf13d6e28b1aef disabled
the menu from the different applications, but later changes in sale
brought back the menu again.

Since it doesn't hurt to have the menu in debug mode, the lowest solution
would be to disable the creation of uoms from the uoms tree view.

closes odoo/odoo#131237

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-10 17:02:07 +02:00
Victor Feyens 405b97cf38 [FIX] website_sale_picking: correctly filter out invalid providers
The 'onsite' payment provider shouldn't be shown to the user
if the cart/order only contains services (or if there are no onsite carriers).
The logic was there but the filtering didn't correctly update the values.

opw-3437107

closes odoo/odoo#131177

X-original-commit: 78cd9a7ab5fb860021a906400a1907b1d8b45be2
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-09 03:08:07 +02:00
Victor Feyens d98c0af075 [FIX] sale_product_configurator: non configurable no_variant attributes
If a given template T has two attributes lines:
* standard attribute (instant creation): one value
* no_variant attribute (never create a variant for it): one value

It will have one automatically generated variant V, which will be automatically
selected on the sale order line if you chose the template T.

If optional product(s) are added on the template T, the configurator will
open to choose the optional products.

But in this situation, the main product was shown as "Option not available"
on the configurator.  This is wrong since there is the valid variant V that we
can use.

This is caused by a behavioral change in 16.0, we saved the variant V directly
on the sale order line, before opening the configurator.  Previously, the values
were applied to the line after the configurator was closed (if there were optional
products).

As the values were applied before the call to `_openProductConfigurator`,
the product.template.attribute.value of V (the standard one, not the no_variant)
is given to the wizard opening, disabling the automatic fallback that previously
gave the two expected ptav's (the standard AND the no_variant one), leading to
an incomplete combination, which was considered invalid.

This commit restores the previous behavior, by setting the product on the line
only if there is no optional products. If there are, everything will be
correctly managed when the configurator is closed.

opw-3355216

closes odoo/odoo#131147

X-original-commit: 902c7112c75841ede560c51d54e12e9cf809ee8c
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-08 20:07:26 +02:00
Victor Feyens 58b90963ba [FIX] sale_product_configurator: do not show unavailable values
Values removed from the product should be hidden instead of being shown
as forbidden values.

opw-3434706

closes odoo/odoo#131145

X-original-commit: 9a581c46dca46ad44957cf1a47748f0c56ad07ca
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-08 20:07:22 +02:00
Victor Feyens 467619a244 [FIX] sale: show more lines on the order form view
Users are not able to reorder lines on order having more
than 40 lines as only 40 lines are shown by default.

In some advanced flows, new lines are automatically added to the
end of the lines and the user has no way to move them back in
the first ones (or in a specific section if it's not on the same
page).

opw-3437983

closes odoo/odoo#130956

X-original-commit: b316cd61bff1c05f8b07d036e9c0409998982a69
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-07 12:32:48 +02:00
Victor Feyens e7317ae8a7 [IMP] website(*)_sale(_*): tours harmonization
* Impose the use of the dedicated tour utils to factorize and harmonize
the way tours behave on the ecommerce.
* Introduce new utils when it seems adequate and useful.

This will reduce incoherences and non determinism in e-commerce tours,
and ease future tasks refactoring the e-commerce design and process
(since we'll be able to restrict most changes to the utils instead of adapting
all the tours one by one).

closes odoo/odoo#130378

Related: odoo/enterprise#44938
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-03 19:31:23 +02:00
Victor Feyens 9d347f3f9d [CLN] website_sale: templates cleanup
* indentation
* coherence of singled/double quotes

Part-of: odoo/odoo#130378
2023-08-03 19:31:22 +02:00
Victor Feyens cdfb25dad5 [CLN] sale_loyalty_delivery: cleanup
Unless necessary, super should be called first, delegeting ensure_one()
and base logic to the base method.

closes odoo/odoo#129572

Related: odoo/upgrade#4987
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-03 19:31:15 +02:00
Victor Feyens 4396f171ef [MOV] (_ => sale_)loyalty_delivery: merge modules
There is no need to have two bridges linking delivery & loyalty.
The two modules held the two parts of the same logic, making no
sense to keep the two modules separate.

Task-3420579

Part-of: odoo/odoo#129572
2023-08-03 19:31:14 +02:00
Victor Feyens 14acd8599e [FIX] website_sale: make test more reliable
The test test_update_cart_zero_qty was checking the total amount
of the cart, but depending on installed localizations, the taxes
vary and the test can fail.

This commit changes the check to the untaxed amount to make sure
the test only depends on the sales price of the product defined in
the test setup.

closes odoo/odoo#130319

X-original-commit: a2c693795081953ed0ba07bfad210701fcf6f1f0
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-02 05:10:44 +02:00
Victor Feyens d364c0a57f [FIX] sale: unreliable test
The test test_product_quantity_rounding fails when the currency
of the company rounds to the unit (decimal places = 0).

This commit makes sure the test doesn't fail with that setup.

Cf runbot build error 20612

closes odoo/odoo#130285

X-original-commit: fae7beacd950fcc349728f98681b6aa281572aa4
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-02 01:15:49 +02:00
Victor Feyens c2c35f32cc [FIX] product: default pricelist should take precedence over new ones
The default pricelist automatically created for companies if the pricelists
are enabled should (like it was before with the Public Pricelist record in
the data) take precedence over newly created pricelists record.

This can be enforced by creating the default pricelist with a higher priority
(lower sequence).

closes odoo/odoo#130232

X-original-commit: ea1e83514bd6190a516f2cf92f800625876b789e
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-01 22:31:01 +02:00
Victor Feyens 13bfb9eecd [FIX] product: correctly create/unarchive default pricelist when enabled
X-original-commit: 5e8547288f83e484ced67c4e44fda6df544f3c09
Part-of: odoo/odoo#130232
2023-08-01 22:31:00 +02:00
Victor Feyens f5de88f3b5 [FIX] sale: failing test with localizations
The test verifying the values of the sale report in a multi-comp & multi-curr
environment relies on the fact that the main company is by default in USD.
Nevertheless, the test fails when a localization is installed (if it changes
the currency of the main company).

This commit makes sure the tests always works, and resurrects the right tool
for that, which was dropped in commit 3752b3166e.

Cf runbot build error 22351

closes odoo/odoo#130201

X-original-commit: a73b5fce4fb02eefc681c55eab8f57cd35105226
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-01 13:51:32 +02:00
Victor Feyens fd2fb212c5 [IMP] payment: allow custom providers to follow standard payment logic
* Generate account payments (and require a journal)
* Be displayed as their custom mode instead of always 'Custom'
...

Commit also includes some side bugfixes/cleanup

task-3347338

closes odoo/odoo#126929

Related: odoo/enterprise#43418
Related: odoo/upgrade#4944
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2023-07-20 03:56:19 +02:00
Victor Feyens d888d2953f [FIX] product: correct currency for default pricelist
If an inactive currency is given as company currency write values,
it is unarchived, but before the company update.

Therefore, if the unarchiving of the currency enables the multi-currency,
a default pricelist will be created for the company, but with the wrong
currency since it still wasn't updated.

This commit postpones the automatic creation of pricelists after the update
of the company, making sure the currency of the pricelist is the expected one.

opw-3423706

closes odoo/odoo#128958

X-original-commit: f7c90e4e1c5b6a3335e7c9b9e209a786d4238434
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-07-18 21:48:39 +02:00
Victor Feyens 45d2f1d971 [FIX] product: archive pricelist when linked currency is archived
X-original-commit: 643d63396026c53f30b819382d8b8c48899ef507
Part-of: odoo/odoo#128958
2023-07-18 21:48:39 +02:00
Victor Feyens 9ac7694b9f [CLN] sale_management: leftover dead code
closes odoo/odoo#120229

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-07-10 21:25:48 +02:00
Victor Feyens f96c5a61a9 [FIX] website_sale: unable to confirm zero-amount cart
When the cart has a zero amount (because of pricelist, coupons, ...),
providers are not loaded nor displayed.
Furthermore, if there is no need for delivery (because the cart only
contains services), delivery carriers logic is not loaded either.

In this case, without carriers nor providers managing the disabling/enabling
of the confirmation button (o_payment_submit_button), the base logic handling
the T&C checkbox didn't properly enable the button when it should have.

Introduced by 608e90e998, already fixed
for payment form by 04059d09dfd7dc57a5c86c842d6fea300e1441aa

opw-3418472

closes odoo/odoo#127950

X-original-commit: d3bcf03adb93d2727ed81e1b9ffe0a2bbc5707b0
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-07-10 16:59:55 +02:00
Victor Feyens 1afc7cd23c [FIX] sale: correctly show discount in order report
Public users do not belong to "feature" groups, so anonymous users
downloading their SO report thanks to the access_token won't ever see
the discount column as the user of the request doesn't belong to the
"Discount" group.

opw-3322583

closes odoo/odoo#129962

X-original-commit: 369d71b9fb013dc87c311da6fbad47692bfcbdaa
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-07-28 14:54:13 +02:00
Victor Feyens 3152e21a19 [FIX] loyalty: hide pricelists restriction for gift cards/ewallets
Finetuning of a3ee978f1b

task-3049956

closes odoo/odoo#129961

X-original-commit: e3201ede6258cdcccc10a2702593255921558a27
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-07-28 14:54:10 +02:00
Victor Feyens 40cc4a7b1a [FIX] sale: do not quick_create sales orders
closes odoo/odoo#127343

X-original-commit: 29c535069d1eee123b844aa89f8f3b43d3a7af71
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-07-06 16:23:59 +02:00
Victor Feyens 1682deacc5 [FIX] product: archived product without attributes
Steps to reproduce:
1. Create a product "My Test Product" (no attribute)
2. Create a quotation, select the "My Test Product" product and confirm the sale order
3. Go back to product and add an attribute "Size" with values "L", "XL"
4. Create another quotation, select the ""My Test Product" product => crash

We consider archived combination of attributes as forbidden combination in
the configurator, but when the archived product doesn't have any attribute,
the `archived_combination` was an empty list, which wasn't supported well
by the product configurator logic (client-side).

To quickly fix this issue, we can simply stop sending empty archived combination
(i.e. when the archived product had no attributes).

opw-3410383

closes odoo/odoo#127335

X-original-commit: ca1ac1a115fe06a0a2d2de0fb131a58019f73631
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-07-06 16:23:56 +02:00
Victor Feyens 9c1e734846 [FIX] core: wrong docstring
closes odoo/odoo#126890

X-original-commit: cd6ed74ab9da0127dcb517177744b44ffcd8558a
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-06-30 10:42:16 +02:00
Victor Feyens 67568f13a6 [FIX] website_sale: portal reordering with advanced attributes
If a cart has multiple lines with the same product (custom/no_variant attributes),
opening the reordering wizard on the portal would fail, because the key used in
foreach would be the same for multiple iterations.

closes odoo/odoo#126151

X-original-commit: 80bce88e73770debe64fb401003dac35cb4f6785
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-06-23 12:07:57 +02:00
Victor FeyensandFlorent de Labarre 0fa7b77ad8 [FIX] website_sale: correctly handle no_variant attributes on reorder
New "Re-order from portal" feature for e-commerce orders was not
considering specified no_variant & custom information on the order at all.

This commit makes sure the information is correctly forwarded to the cart,
ensuring the reordered products are the same as the ones previously ordered.

opw-3380312

X-original-commit: 9e774cf88398b7ffc701c4adf44451e39963db08
Part-of: odoo/odoo#126151
Co-authored-by: Florent de Labarre <florent.mirieu@gmail.com>
2023-06-23 12:07:57 +02:00
Victor Feyens bdc6e3e3aa [FIX] website_sale: do not offer reordering for delivery lines
X-original-commit: 79014398c0655ed0c10b85ed3eaa498a5c63bef4
Part-of: odoo/odoo#126151
2023-06-23 12:07:57 +02:00
Victor Feyens b1427153f8 [FIX] sale: forbid payment term change on confirmed SO
Same behavior as for pricelist.

closes odoo/odoo#115871

Related: odoo/enterprise#38427
Related: odoo/upgrade#4452
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-06-22 15:40:51 +02:00
Victor Feyens d2eb6b7143 [FIX] website_sale: confirm SO as superuser
* Make sure the logs are coherent (all done as Odoobot)
* Correctly apply auto-lock setting on e-commerce orders

Part-of: odoo/odoo#115871
2023-06-22 15:40:51 +02:00
Victor Feyens f5f54899a9 [CLN] sale_stock: remove old strange logic
Commit b30afcbdb9 introduced
a strange logic where the invoice status was magically considered
invoiced on locked orders if there was no pending stock logic and
the full delivered qty was invoiced.

Following our removal of the locked status, replaced by another boolean field,
we consider it's wrong to rely on the locked status for functional logic,
therefore removing this old logic.

If it's really a problem (and comes back in the future), another clean solution
will be thought and implemented.

task-3163931

Part-of: odoo/odoo#115871
2023-06-22 15:40:51 +02:00
Victor Feyens 17bece3e79 [REF] sale,*: remove locked (done) SO state
It's not a specific state, it should be considered separately,
as a boolean.

This allows to reduce code complexity (flows should not rely (much) on
the locked logic) and to have a clearer flow.

Task-3163931

Part-of: odoo/odoo#115871
2023-06-22 15:40:51 +02:00
Victor Feyens ceb1bebc0b [REV] website_sale: stop handling exclusions in /shop
Commit 91d0e9c645 made sure that excluded
combination did not appear in /shop search results, but it significantly
slowed down searches, even in databases without exclusions.

Since the excluded combinations cannot be added to the cart (and the
original feedback did not come from an effective ticket), we believe
the gain is not worth the cost.

This commit reverts that change.

Task-3326948

closes odoo/odoo#125722

X-original-commit: 3082ac99dc195a89e1299be73ef149f40231f86e
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-06-20 15:58:33 +02:00
Victor Feyens b31a6aec1c [IMP] product,(event_*)sale: clarify (& deprecate) pricelist context
The whole contextual price of products relies on multiple context keys:
* uom
* pricelist
* quantity
* date

The related logic has already been partly removed/deprecated on products,
but the computation of discounts for events/event booths are still relying
on that logic, though imperfectly.

This commit makes sure this hacky logic (relying on those contextual keys)
is as clear and reliable as possible.
We factorize and harmonize the remaining use cases, with a dedicated constant
and specific methods, making sure:
* currency conversion
* price & discount computations
are coherent, while clearly explaining that it should not be used for
any new feature/logic/code.

We also restrict context updates as much as possible (there won't be
any discount when the pricelist is configured to hide the discount from the customer)

closes odoo/odoo#123848

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-06-20 15:58:03 +02:00
Victor Feyens 71e10bc650 [FIX] sale: multi-company conflict at reinvoicing
Since d88409e8e5ce77ff3ec3b24fcdc108d8df380994, taxes from different companies
are forbidden on sale.order.line records (which is the expected behavior).

Nonetheless, this highlighted some flows where the taxes were not properly
set/recomputed, especially re-invoicing, which is fixed by the current commit.

Fixes #123675

closes odoo/odoo#125434

X-original-commit: 6ce4019968bd0a1a11475910d35aa2ccfc2c6a9a
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-06-16 23:01:14 +02:00
Victor Feyens 4e6db76aba [IMP] product,sale: extract computation of price before discount
So that we can in the future harmonize more easily the discount
computation between sale, point_of_sale, e-commerce, ...

closes odoo/odoo#123849

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-06-06 13:10:31 +02:00