Commit Graph
1074 Commits
Author SHA1 Message Date
Victor Feyens 33f58b2824 [IMP] sale_*: clean order line name computation
* make sure full content is translated in partner language
* drop useless product param (use line product_id field instead)
* delegate order lines name computation to computes for ecommerce carts

closes odoo/odoo#82620

Related: odoo/enterprise#23432
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-01-12 16:43:37 +00:00
Nasreddin Boulif (bon) c40aadb42b [FIX] sale,website_sale: Display extra prices with taxes included
Steps to reproduce the issue:

  - Install eCommerce module
  - Go to Settings
  - Ensure `Product Prices` is set to 'Tax included'
  - Create a new Product as storable
  - Set `Sales Price` to $1.0 and `Customer Taxes` to 10.00 %
  - Under `Variants` tab add an Attribute with 2 values
  - Set "Price Extra" to $2.0 to one of the variants
  - Go to the Shop and select the product

Issue:

  The extra price badge does not include the taxes
  ($2.0 instead of $2.2), however the final price does.

Cause:

  The price_extra field from ptav (used in the badge) does not include
  the taxes.
  However, when calculating the final price, we do first the sum of all
  prices (including the extra prices) and then apply the taxes.

Solution:

  In the template, for each 'variants', we call `_get_combination_info`
  to get the variant.price_extra with taxes included/excluded
  depending the `Product Prices` setting.

opw-2669871

closes odoo/odoo#81949

X-original-commit: 6f04935d14d595faa3bb8dd6ba9e0dcf1d694886
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Nasreddin Boulif (bon) <bon@odoo.com>
2022-01-12 10:17:43 +00:00
Victor Feyens 009237b463 [IMP] sale_*: avoid fetching unnecessary data
Do not fetch products attributes specifications if there is no 
custom/no_variant attributes specified on the SOline.

Also update query counters according to recent performance changes 
(batched followers insertion and other things)

closes odoo/odoo#81585

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-01-04 12:06:39 +00:00
Yannick Tivisse bbd65b8a3a [IMP] product,sale: Convert _onchange_type into compute methods 2021-12-23 15:30:23 +01:00
Yannick Tivisse 9e99a9df46 [IMP] product: Remove price/pricelist_id field from template/variant
Purpose
=======

The fields are not used, don't work correctly and there is a specific
report to generate the product prices according to the pricelist and
the ordered quantities
2021-12-23 15:30:23 +01:00
Victor Feyens 002d13729a [FIX] sale: make update_prices work correctly if called twice in same request 2021-12-23 15:30:23 +01:00
Victor Feyens 0acd96c340 [IMP] sale: Use a 'cached' pricelist rule mechanism
Cache the pricelist rule used for price computation in a dedicated non
stored field, since it is used both for the price_unit and the discount
computation.

This divides by 2 the number of pricelist requests/queries when
discounts computation is enabled.
2021-12-23 15:30:23 +01:00
Victor Feyens 493866c37d [IMP] sale, *: clean _get_display_price
* remove error prone product param
always use the product of the line instead.
* also move the method near the place where it's called
2021-12-23 15:30:23 +01:00
Victor Feyens bb1cf7d7ce [IMP] sale: delegate update_prices logic to the computes
Remove duplicated price & discount computation and trigger
the necessary computes.
2021-12-23 15:30:23 +01:00
Victor Feyens 57ced812f0 [REF] product: clean pricelist API
* Do not rely on context, everything should be cleary specified through
parameters
  Catch context keys in an unique targeted place to improve code clarity
* Drop strange old API
  * do not provide unused partner parameter anymore
  * do not provide products, qty as a list of tuple, we only request the
same qty for all products anyway
* Clear methods, add/adapt comments and docstrings
* Reduce potential side-effects of context content.
2021-12-23 15:30:23 +01:00
Thibault Francois 2daa9a1673 [FIX] sale: send invoice only when ready to be send
Issues
------

In the module sale, with the automatic invoicing configured.
Payment transaction generate, post and send the invoice when
they are post process.

In some country the invoice is not directly ready to be sent
due to some edi document

Solution
--------

use the mechanism introduce with https://github.com/odoo/odoo/commit/3a29371eb70309f46e3b8938434287fefc23b351
to delay the sending. Introduce a cron that check invoice to send

closes odoo/odoo#81526

X-original-commit: 97b74d8304337d901d9422418cbd0dcdcc46fcf5
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2021-12-22 14:02:37 +00:00
Thibault Francois a592e3a368 [FIX] sale: avoid concurrent update on invoice
Issue
-----

When a customer sign and pay a sale order from the portal and
automatic invoicing is enabled, it generate an invoice.
Once the payment done the customer is redirected to
the sale order preview with a link to the invoice created.

To display the link to the invoice the method _portal_ensure_token() is
called and write the access token token.

In parallel, if the invoice need to send edi document, the cron job is
triggered at the posting of the invoice and thus the cron job try to
write as well on the invoice as the invoice link is displayed to the
customer

This lead to a concurrent update for the cron job that do not retry in
case of concurrent update as normal transactions do. So the edi document
is never synchronized and the invoice never sent

Solution
--------
Avoid to write on the invoice while displaying the sale order portal
view by already generating the access_token in the transaction that post
the invoice

closes odoo/odoo#81731

X-original-commit: ccf76a5b8c0671e69e8875ea476d13005dab8d72
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2021-12-21 13:47:03 +00:00
Thibault Francois 31e610f7a3 [FIX] purchase, sale: Fix multicompany fiscal pos access
Context
-------

On some database, record rule may be configured in such a way
that user are able to read Purchase/Sale order
with a company_id != user.company_ids

Issue
-----
This commit https://github.com/odoo/odoo/commit/4dd150950274b1d7c3b24b7665443318f94323f6#
introduce a new field tax_country_id that require to be able to read
the fiscal.position as well.

The reading of a sale.order or purchase.order should not require the
right to read the fiscal.position for the computation of a technical
field only use during the modification.

Solution
--------
Compute tax_country_id as sudo

closes odoo/odoo#80049

X-original-commit: b329c3b18197ac6db5ffdf3cb4945a14997a1f0b
Signed-off-by: Olivier Dony <odo@odoo.com>
Signed-off-by: Thibault Francois <tfr@odoo.com>
2021-12-21 13:46:55 +00:00
Yolann Sabaux fcd6610bcc [FIX] sale: fix rounded discount
Steps to reproduce:
- Install and launch sales
- In settings: activate price lists and discount; price list based on advanced rules
- Create a new price list; based on percentage (54%)*; applicable on all products; show discount
- Make sure the Public Price List has show discount activated
- Create a new quotation
- Select the Test pricelist
- Select a product (price 0.03 eur/$/other)*
- Change the price list to Public price list
- update the prices
- change the price list to Test price list
- update the prices
-> The Discount shown is not the one defined in the price list (66.67%)*
*(values for my example)

Solution:
Use the real price and not the a posteriori-rounded price for the computation of the discount  in the `update_prices` method.

opw-2677884

closes odoo/odoo#81395

X-original-commit: 986dbc20952caae9d5a1b4b7ee34cfb994dea077
Signed-off-by: yosa-odoo <yosa@odoo.com>
2021-12-16 09:51:50 +00:00
svs-odoo 6d034d9e52 [FIX] *sale*: exception when cancel SO
The commit ca7d5701c6a46f7781bdc9af9f2d26cca880eb93 fixes issue with
backorder being to quickly canceled but as it call `action_cancel`
before the condition who's looking on the SO state, the condition can
never be matched as the SO state will always be `cancel`.
So, the exception about the SO being cancelled will not be logged on
following documents.

How to reproduce:
  - Create a product and enable route MTO + Manufacture on it and create
    a BoM for this product;
  - Create a SO for this product and confirm it;
  - Cancel the SO and check the generated MO => There is no exception
    about the cancellation of the SO.

This commit fixes this issue and doesn't impact the previous fix.

task-2657799

closes odoo/odoo#79215

closes odoo/odoo#81178

closes odoo/odoo#81401

Related: odoo/enterprise#22008
Related: odoo/enterprise#22814
Related: odoo/enterprise#22896
Signed-off-by: Arnold Moyaux <arm@odoo.com>
2021-12-14 18:23:03 +00:00
Camille Spiritus 3732aea4b8 [IMP] account,sale: move partner_shipping_id field from sale to account
The computation of 'partner_shipping_id' is now done using a 'compute' instead of 'onchange'.

task-2601934

closes odoo/odoo#78449

Related: odoo/enterprise#22098
Related: odoo/upgrade#3000
Signed-off-by: Laurent Smet <las@odoo.com>
2021-12-14 14:47:25 +00:00
Thibault Delavallée 03004aa95d [FIX] sale: do not force order responsible
With recent update to computed fields [1] order responsible is now always
changed to the partner responsible, or its commercial entity responsible.

This cause issues, notably with ACLs 'own documents only'. Indeed a salesperson
could update or set a partner on an order that would change the responsible and
lead to ACLs issues. Moreover some functional flows automatically set a partner
(online registrations, ...) that would make the responsible change without a
clear notification or warning.

We prefer to keep a less intrusive behavior, aka setting a responsible when
no one is set.

Task-2703285 (event performance)
Task-2703289 (event testing)

[1] odoo/odoo@210c9daebc

closes odoo/odoo#81025

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-12-08 09:35:08 +00:00
Victor Feyens 6e122d8ccb [IMP] sale: currency rate computation performance
* should not be triggered when pricelist is changed, only if currency is
modified
* cache results to reduce sql queries
2021-12-02 12:12:04 +01:00
Victor Feyens 31c3894b80 [REV] sale: do not precompute fields depending on x2m
and do not force precomputation on side models, it would reduce their performance.
2021-12-02 12:12:04 +01:00
Victor Feyens b8a0fe79f4 [IMP] sale: remove fpos fallback in SOL compute 2021-12-02 12:12:04 +01:00
Yannick Tivisse 2541fe2067 [IMP] sale: Use a cache to avoid computing several time the same sales team 2021-12-02 12:12:04 +01:00
Yannick Tivisse 79dedf5024 [IMP] sale: Don't fetch fiscal position if nothing to map 2021-12-02 12:12:04 +01:00
Yannick Tivisse 0f2edc94bf [IMP] sale: Use a cache to compute fiscal positions 2021-12-02 12:12:03 +01:00
Yannick Tivisse 232d66069a [IMP] sale: Make some field precomputed 2021-12-02 12:12:03 +01:00
Yannick Tivisse 48401aa9a0 [IMP] sale: Convert _onchange_partner_shipping_id into computed field 2021-12-02 12:12:03 +01:00
Yannick Tivisse 28b66bad31 [FIX] sale: Erase product attributes values if no product on SOL 2021-12-02 12:12:03 +01:00
Yannick Tivisse 795aa94cef [IMP] sale: Make several fields pre_compute=True to avoid double computations 2021-12-02 12:12:03 +01:00
Yannick Tivisse 3c07a3fecd [IMP] sale: Apply misc styling improvements + remove dead context keys 2021-12-02 12:12:03 +01:00
Yannick Tivisse 280cf015e1 [IMP] sale: Use compute method for notes + translate field in default value 2021-12-02 12:12:03 +01:00
Victor Feyens da35c78dd8 [IMP] sale: rely on related fields instead of taking them from the order 2021-12-02 12:12:03 +01:00
Victor Feyens 096e8a3b95 [FIX] sale: do not recomputed price_unit on partner change 2021-12-02 12:12:03 +01:00
Victor Feyens 2905c565d2 [FIX] sale: avoid defaults on compute stored fields
Leave the computation fully to the compute method, to avoid side-effects 
and wrong values in db.
2021-12-02 12:12:03 +01:00
Victor Feyens d9f9826b93 [FIX] sale(_stock): do not override customer_lead compute with default 2021-12-02 12:12:03 +01:00
Victor Feyens bc945ef3f2 [FIX] sale: remove wrong default qty on lines
Compute was never called because of the compute, which lead to wrong
values (raising due to the SQL constraints).

Integrate the default in the compute directly.
2021-12-02 12:12:03 +01:00
Victor Feyens 886d6093f1 [IMP] sale: remove default for fully computed fields
Will be triggered and returned by default_get calls for nothing
2021-12-02 12:12:03 +01:00
Victor Feyens 3314036f71 [IMP] sale: pre-compute stored related fields 2021-12-02 12:12:03 +01:00
Victor Feyens 302ad13b3d [IMP] sale,account: follow same pattern for all compute methods 2021-12-02 12:12:03 +01:00
Victor Feyens 1d3b9f6be6 [IMP] sale: minor perf improvement & cleanup 2021-12-02 12:12:02 +01:00
Victor Feyens 1d854b0bb6 [IMP] sale: correctly consider display_type in SOL computes 2021-12-02 12:12:02 +01:00
Victor Feyens 2de16205d2 [IMP] sale: clean date(time) conversions
* remove conversions from & to strings, odoo manages date(times)
natively
* clean imports
2021-12-02 12:12:02 +01:00
Victor Feyens 54fa80c24f [FIX][IMP] sale_*: clean customer_lead code
* remove useless hook _get_customer_lead, since the field is now 
computed
* Add inverse to properly modify existing stock moves when the customer 
delay is modified
2021-12-02 12:12:02 +01:00
Yannick Tivisse de4911aceb [IMP] sale: Remove qty_delivered_manual field
This field is useless since the new compute method from 13.0.

And also introduces side effect / loop recomputations.
2021-12-02 12:12:02 +01:00
Yannick Tivisse fecff7119f [IMP] sale: Don't recompute taxes on tax configuration change
This should be done manually
2021-12-02 12:12:02 +01:00
Yannick Tivisse 01557bf36e [FIX] sale: Split _compute_order_info_from_partner into several methods 2021-12-02 12:12:02 +01:00
Yannick Tivisse 052b15e823 [IMP] sale: Convert _change_sale_ok into compute method 2021-12-02 12:12:02 +01:00
Yannick Tivisse 728cb1b15f [IMP] sale: Remove useless pre-precessing on SOL creation
This is not needed anymore since the last ORM changes from this PR
with the pre_compute attribute.
2021-12-02 12:12:02 +01:00
Yannick Tivisse 1003ef0e70 [IMP] sale: Convert _onchange_discount into compute method 2021-12-02 12:12:02 +01:00
Yannick Tivisse 916e92aa30 [FIX] sale: Split product_id_change into several compute methods 2021-12-02 12:12:02 +01:00
Yannick Tivisse 8a6093c612 [FIX] sale: Add misc missing computation triggers 2021-12-02 12:12:02 +01:00
Yannick Tivisse b16b3e32f7 [IMP] sale: Convert _onchange_product_packaging_qty into compute method 2021-12-02 12:12:02 +01:00