Commit Graph
412 Commits
Author SHA1 Message Date
Christophe Simonis 522c8cd783 [FIX] delivery: correct selection value
Oversight of view-pocalypse (odoo/odoo#104741) that wrongly changed it.

closes odoo/odoo#132408

Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
2023-08-19 12:02:42 +02:00
Gorash 1e12f68a1d [REF] base,all: Update modifier syntax: prepare view migration
These changes are made as a result of simplifying attrs and 'states' in
views.

Before applying the migration script, it is necessary to fix some views.
These views are erroneous and either work by chance or are simply
untested. We have for example wrong domains, elements used by modifiers
but not present in the view, obsolete domain operators, inherit views
not targeting the right views, xpaths using attributes as target, the
use of %(...)s in views, false attribute value types in python.

Part-of: odoo/odoo#104741
2023-08-18 09:49:12 +02:00
Michael Tietz 2f6b44d7e0 [IMP] delivery: Make delivery line creation and selection hookable
closes odoo/odoo#131047

X-original-commit: 1242d6309b9b76c2bea5606facd81d6d20fa8b65
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-08-11 21:32:53 +02:00
william-andre 0479b2b594 [IMP] account,*: manage subsidiary companies
Allow sharing records between company
* accounts
* taxes
* fiscal positions
* products
* ...and some related models

These records can be read and used in children companies.

This can be used to
* have different branding for different businesses
* allow more complex security rules
* consolidate branches differently
* manage different tax reports with different tax ids in the same
  country

task-3371677

closes odoo/odoo#125642

Related: odoo/enterprise#43215
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
2023-07-20 11:49:06 +02:00
Valentin Vallaeys (vava) 129618ae41 [FIX] (stock_)delivery: no stock.picking in delivery
In this commit
https://github.com/odoo/odoo/pull/121354/commits/7d1092ba0e970170ce66e77e6ddc4cab0e09563d
the forward-port automatically moved the test to `stock_delivery` but
the code change remained in `delivery`. Since it handles `stock.picking`
on a `sale.order`, and that `delivery` does not depend on `stock`
anymore, it should move to `stock_delivery` as well.

closes odoo/odoo#123993

X-original-commit: d5b64650d043f94f8e244c993eff36ed26a93a32
Signed-off-by: Vallaeys Valentin (vava) <vava@odoo.com>
2023-06-06 20:27:41 +02:00
Eteil Djoumatchoua (etdj) 171aa0ec25 [FIX] delivery_carrier,sale_giftcard: get the right shipping price even with gift card
Step:
- Create a product with sale price 120 USD
- Create a giftcard with balance 40 uSD
- Create a free Shipping cost of 40 USD fixed price and freeing above 100 USD
- Go to website->shop, select the product and checkout the cart(the shipping is free because price exceeds 100)
- Add the gift card to payment

Issue:
The shipping price gets from free to 40

Cause:
When computing the cost of the shipping the fact of the presence of a giftcard is not considered.

Solution:
Create a method to returns the amount of giftcard from a sale order and add to total price to check if the shipping is free

opw-3107284

closes odoo/odoo#120174

X-original-commit: c57184fd1c3d2846df4f618dee0027364eb62596
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
Signed-off-by: Djoumatchoua Eteil Junior (etdj) <etdj@odoo.com>
2023-05-16 13:36:59 +02:00
kir-odoo 88bcd855ae [FIX] delivery: shipping carrier is set after delivery generated
Before this commit
==================
when SO is confirmed and Delivery is created then add the shipping method
in SO, in this case, the shipping carrier is not set in the existing undelivered
delivery of that SO.

After this commit
=================
So in this commit, we set the shipping carrier for undelivered delivery.

taskId - 2946360

closes odoo/odoo#121363

X-original-commit: 51523c0dbf6ce9dd1a1ff35e03fa6a51267da14b
Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-05-15 11:41:57 +02:00
prye-odoo c4dc4735c4 [FIX] delivery: prevent trace back while partner has no zip
In delivery address, `country name` and in shipping method, `country name`
will be same and no zip in delivery address.  While creating new sale order
along with product and clicking on "Add shipping",  error will be generated.

Steps to Reproduce
-Install `sale_management' and 'delivery' modules
-Go to the settings and enable the 'Customer Address'.
-Go to the settings and enable 'Shipping Methods' and configure it.
-Select a shipping method and  go to the 'Destination Availability' tab and
 set to the 'Countries' and set to 'Zip Prefixes'.
-Create a new customer and add the delivery address of the customer in
 res.partner.
-The delivery address and shipping method of the 'Countries" or 'Country'
 name should be the same.
-Set the  'Zip Prefixes'
-Set the delivery address of zip code null.
-Create a new quotation and add to the customer and delivery address
-Add to the product in the sale order line.
-Click on the 'Add Shipping' or 'Update Shipping Cost' button.

A trace back will be generated.

Applying this commit will resolve this issue.

sentry-4147077852

closes odoo/odoo#120968

X-original-commit: 60d5c7d5668da542e251d7d6fb8774043cfddea8
Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-05-10 20:15:38 +02:00
althaf shaik 77f7cc2eb1 [FIX] delivery: price rule name not formatted if no delivery product
This trace back raises when we try to create delivery price rule,
while delivery product is not selected in the delivery carrier.

Steps to produce:
 * Install delivery,sales modules
 * Open Sales/Configuration/Shipping Methods
 * Create a new shipping method keep provider as 'Based on Rules'
 * Try to add a line for pricing
 * At this moment trace back raises ('Expected singleton: res.currency')

We resolve this issue by not formatting the name if the currency does
not exist yet, as the currency is related to the one of the product.

Sentry :- 4067992652

closes odoo/odoo#119958

X-original-commit: d20431758c0c4943394a63250ad0a83894b795c8
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2023-04-27 18:25:23 +02:00
Victor Feyens f4ea6d3226 [FIX] *: strict api for main orm methods
Enforce strict types for returned values for
* create
* write
* unlink
* default_get

to make those methods more consistent and reliable.
Also make sure they can be called with empty self/values,
i.e. that they follow the same behavior as the base methods
defined in the main orm Model.

closes odoo/odoo#116809

Related: odoo/enterprise#38880
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2023-04-25 15:20:43 +02:00
kir-odoo 71a2c5a551 [FIX] delivery: exclude neg qtys from shipping weight
This commit prevents inclusion of negative qty SO products from
the calculation of its estimated shipping weight. Negative qtys can
indicate a return, which would be a separate picking from the delivery
 => we shouldn't subtract their weight from the delivery. This
subtraction, may have resulted in shipping rates being calculated as
lower than they should have been within the SO.

Additionally fixes the following use case (requires Fedex connector):
- create a SO with 2 products with the same weight
- set 1st product qty = 1
- set 2nd product qty = -1
- add shipping => Shipping Method = Fedex US
- click on "Get Rate"

An error will occur because the SO._get_estimated_weight() = 0, and
you cannot have a rate for weight = 0

TaskId - 3028023

closes odoo/odoo#118348

X-original-commit: ecf0262e3ef746c33a29c4f2de7868e3ab61cce2
Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-04-13 05:07:36 +02:00
Valentin Vallaeys (vava) d3cddbe89a [FIX] delivery, website_sale: fix UX issues in views
In ecommerce, the form vue of shipping methods should be improved to
easily set up fixed delivery costs. This commit improves the
user-experience and solves bugs on the fields displayed.

task-3203210

Part-of: odoo/odoo#110686
2023-03-14 12:23:45 +01:00
Valentin Vallaeys (vava) a54c304487 [REF] (stock_)delivery: split delivery from stock
Extract the Inventory logic from the `delivery` module into a new
`stock_delivery` module. This will allow to integrate the basic delivery
features into the website_sale app in a one-app free database.

task-3074497

Part-of: odoo/odoo#110686
2023-03-14 12:23:44 +01:00
Martin Maes 2b907e9f95 [IMP] deliver: add fixed margin
Removed the margin on rate when the provider is Fixed Price

Removed the margin on rate, free, amount when the provider is Based on Rules

Added a fixed margin for all the other providers

task-3043063

closes odoo/odoo#108794

Signed-off-by: Steve Van Essche <svs@odoo.com>
2023-03-06 18:52:41 +01:00
LSE ef3bbc9293 [FIX] delivery: add commodities for packages from order
Before this commit:
1. Set up an EasyPost shipment setup, using
"Canada Post" as the Carrier Type and
"XpresspostUSA" as the Default Service Level.
2. Create a SO with a US customer (like Deco Addict)
3. "Add Shipping" using the button and choose the one created in 1.
4. When you try to "Get Rate" using the EasyPost shipment,
the API does always return the same error:
```
Easypost returned an error:
Unable to proceed, 'customs_info' is required for
international shipments, shipments bound for US
military bases, or US territories. Please see
https://www.easypost.com/docs/api#customs for more information.
```

After this commit:
As no commodities were set, `_customs_info` will return
an empty dictionary.
To solve that, we set the `DeliveryPackage` commodity
value on its initialisation to compute the customs
information the way it should.

opw-3104305

closes odoo/odoo#112988

X-original-commit: 06beca4373743787ae629b2c7ea623bf0583727a
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2023-02-21 15:53:11 +01:00
Touati Djamel (otd) f8cac8d384 [FIX] delivery: wrong delivery price for real cost in so
Steps to reproduce the bug:
- Install FedEx delivery
- Go to the shipping method > FedEx:
    - Select Real cost and margin on rate 10%
- Create a storable Product “P1” and update its qty
- Create a SO:
    - Add the product “P1”
    - Click on add shipping
    - Select FedEx and get the rate
    - Imagine the price is $10 and with margin it's $11

- Confirm the SO and process the delivery

Probelm:
The shipping price will be $12 instead of $11 in the SO

Because the estimated price is calculated the first time with margin
and added in the picking when sending to the shipper:
https://github.com/odoo/odoo/blob/afed7db30042e2ea91cdae292dadb7b6f742e33d/addons/delivery/models/stock_picking.py#L226

Then, the delivery cost is added to the SO, but the margin is applied a
second time:

https://github.com/odoo/odoo/blob/afed7db30042e2ea91cdae292dadb7b6f742e33d/addons/delivery/models/stock_picking.py#L246

https://github.com/odoo/odoo/blob/afed7db30042e2ea91cdae292dadb7b6f742e33d/addons/delivery/models/stock_picking.py#L262

so this commit is useless:
https://github.com/odoo/odoo/commit/632767d83e0f42acc5b486bde02dd1d9c2533911
because the `_add_delivery_cost_to_so` function is called only when
sending to the shipper

opw-3184482

closes odoo/odoo#113064

X-original-commit: b8c4fcbc1cba369dce8296b800565dfd181957a4
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2023-02-20 10:29:57 +01:00
Stefan-Calin Crainiciuc (stcc) 383efd3d22 [I18N] delivery_grid: improved translation
Steps to reproduce:
- Install eCommerce, delivery
- Shpping methods > Create > Name = TEST, Product = Acoustic Bloc Screen,
Provider = Based on rules, Add a line > Condition = "Weight <= 0",
Delivery Cost = "50 + 0 * Weight" > Publish shipping method
- Go to the website > Add acoustic Bloc Screen to cart > Proceed to checkout

In the delivery section, the TEST shipping method will display the
warning message `No price rule matching this order; delivery cost
cannot be computed.` This message can be confusing to the customer.

opw-3110715

closes odoo/odoo#112002

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-02-08 14:30:50 +01:00
Valentin Vallaeys (vava) f7c033eff7 [MOV] delivery: rename and split files by model names
Part-of: odoo/odoo#111748
2023-02-03 11:45:42 +01:00
Valentin Vallaeys (vava) ce35703ca3 [CLN] delivery: super(class, self) is not needed
Part-of: odoo/odoo#111748
2023-02-03 11:45:42 +01:00
Valentin Vallaeys (vava) 29060f3e06 [CLN] delivery: alphabetical order and guidelines for imports
Part-of: odoo/odoo#111748
2023-02-03 11:45:42 +01:00
Valentin Vallaeys (vava) fcfcc1b190 [CLN] delivery: remove utf-8 header in python scripts
Part-of: odoo/odoo#111748
2023-02-03 11:45:41 +01:00
Wolfgang Taferner ed8b0cb1dc [FIX] delivery: update_prices does ignore shipping rate
As sale does not know about special lines it will always update
the price based on product and price list instead of applying the correct
shipping rate, so we do skip those lines by using a newly introduced hook method

closes odoo/odoo#110782

X-original-commit: f1265b7fdce6bbe3fea97fc4b275dc2dca18103d
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2023-01-24 10:20:38 +01:00
PNO 9807aa9186 [FIX] delivery: speedup compute bulk weight
On the PR https://github.com/odoo/odoo/pull/107558 some performance improvements were made when computing the weights.
Unfortunately, this caused some slowdown on other cases.
This PR keeps the read_group introduced on https://github.com/odoo/odoo/pull/107558 but reduces the number of 'get' by taking all the information needed only once before entering the for loop.

For comparison, these are the differences on _compute_bulk_weight when going to Inventory/Receipts:

| Before PR 107558  | After PR 107558 | After this PR
| -------------     | -------------   | ------------- |
| 550 ms            | 10.30 s         | 560ms  |

And these when removing the filter by default (leading it to fetch heavier records):

| Before PR 107558  | After PR 107558 | After this PR
| -------------     | -------------   | ------------- |
| 2.27 s            | 24.48 s         | 1.89 s |

OPW-3107540

closes odoo/odoo#109481

X-original-commit: 4bbf782505e72761c7c77abfe4fbd53e151e5bf0
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-01-11 09:38:49 +01:00
ノウラ 64780b824b [FIX] delivery: speed up delivery costs installation
Due to hefty data the RAM limit gets exhausted.
The process gets killed due to the computed field weight on
- stock.move
- stock.picking
When installing the delivery costs module.

To solve the problem:

We add the column weight to the DB schema.

Ticket ids:
- 3013955
- 2628251
- 3028081

closes odoo/odoo#109164

Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-01-05 13:09:17 +01:00
Denis Roussel ca17c97920 [FIX] delivery: Really use propagate_carrier option on stock rules
closes odoo/odoo#108501

X-original-commit: c41d64507cd08c6e6cb033e8802d537acce5aaab
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2022-12-22 14:49:26 +01:00
Ahmed Khalaf (ahkh) be58a41cbb [IMP] delivery: set weight for shipping rate
Previously, when adding shipment to sale order, the user did not know
the total weight of the order when getting rate of shipping method.
This commit shows the total order weight to the user with the ability to
set it to any value to get the rate with.

Taskid: 2797613
Part-of: odoo/odoo#96660
2022-12-15 10:31:12 +01:00
Aurelien van Delft (avd) 81773cd70f [FIX] delivery: read_group fest speeding up weights compute
Currently _compute_bulk_weight and _compute_weight are
going through each picking in self and each stock_move_line
in picking.move_line_ids to compute the pickings' weight.

This can be slow when there are lots of move_lines by pickings
as the field cache will be filled by the move_lines records
and uom._compute_quantity will be called once by move_line.

This is especially true for pickings with SN-tracked products.
For SN tracked products there will be one move_line by product_qty
(so a picking with 1 SN tracked product with a qty of 100 will have
 100 move_lines). In this case doing a read_group yields the highest
speedup.

Following the same reasoning a search_count is done in _compute_packages
before retrieving package.move_line_ids.
When package.move_line_ids.result_package_id is empty doing a count
is much faster as it avoids calling _in_cache_without for the package
move_line_ids. The search_count overhead is negligeable in the other
case so adding it leads to an overall speedup on average.

opw-3017013

closes odoo/odoo#107994

X-original-commit: c95abbe8fa09decca2f94a035934e8d6ae7903e1
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Van Delft Aurélien (avd) <avd@odoo.com>
2022-12-14 22:04:20 +01:00
Achraf 0801d1a92e [FIX] delivery: Fix ZeroDivisionError in shipping cost calculation
A `ZeroDivisionError` traceback  that occurs in `delivery/DeliveryCarrier:_get_packages_from_order` was caught by Sentry

Because in this part of the function

https://github.com/odoo/odoo/blob/c18064d717312287f5acba2fabeb77b2e1c01fb9/addons/delivery/models/delivery_carrier.py#L326-L335

if `total_weight === 0.0` then `total_full_packages` and `last_package_weight` will be null too.
And that will cause a `ZeroDivisionError` because of `total / len([])`

opw-3086602

closes odoo/odoo#107820

X-original-commit: a362e14ee62a5d9d2bcb08c4431994a96796ce1e
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-12-14 11:41:57 +01:00
pedrambiria ccaecba252 [FIX] delivery: accept regex in the zip prefixes field
In the country of Bahrain, they have 3 and 4-digit zip codes. With the
current implementation of the delivery module, they can not add 3-digit
zip codes because they will be matched with some 4-digit zip codes,
which is incorrect.

For example, consider '101' and '1011' as two different zip codes related to
two separate zones. If you add '101' to a delivery method, it would also
accept '1011'.

The solution is to accept regular expression to allow them to use $ to
define the end of the zip code.

opw-3072592

closes odoo/odoo#107636

X-original-commit: 0a68d171af2645d3047d561acb354730aebfa753
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-12-09 18:37:50 +01:00
Goffin Simon 76199fd956 [FIX] delivery: Multi currencies with free shipping above amount
Steps to reproduce the issue:

- Let's consider two currencies C1, C2
- Let's consider two pricelists P1 in C1 and P2 in C2
- Let's consider that the current company CY has the default currency C1
- Let's consider that the current rate of C1 = 1.0 and C2 = 5.0
- Create a shipping method SM with fixed price = 50 and free shipping is above 100 (expressed in company currency)
- Create a SO with P2 and add a line with a product of 200 C2 (equal to 40 C1)
- Add shipping method SM

Bug:

The shipping was considered as free but the total of the SO was not above 100 in the currency of the company

opw:3010266

closes odoo/odoo#107456

X-original-commit: c93ab6615f0370963b152cc0320478fe4ceed164
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-12-08 13:38:06 +01:00
Touati Djamel (otd) 42f9a2c2da [FIX] delivery: avoid a traceback when calculating the shipping cost
Stpes to reproduce the bug:
- Install delivery_ups
- Go to shipping method > UPS BE > Package type
- Set the max weight to 10 kg
- Create a product “P1”:
    - Go to inventory tab > weight: 10 kg
- Create a SO:
    - Add the product “P1”
    - Add shipping
    - Select UPS Be
    - Click on get rate

 Problem:
Traceback is triggered, because we devise a number by an empty list:
https://github.com/odoo/odoo/blob/6b0ab28791f4a29254d294f8a116545d4c124e8b/addons/delivery/models/delivery_carrier.py#L301

The `last_package_weight` is the result of the modulo of the weight of
all the products by the maximum weight of a package, in this case it is:
0 -> 10% 10

We then use this result to calculate the weight of the package,
but parenthesis have been forgotten and therefore an empty list is
returned in the case where `last_package_weight` is 0

https://github.com/odoo/odoo/blob/6b0ab28791f4a29254d294f8a116545d4c124e8b/addons/delivery/models/delivery_carrier.py#L298-L300

opw-3075295

closes odoo/odoo#106863

X-original-commit: f173300f4f24d600693ab54c8db0995723a304e9
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-12-01 13:31:02 +01:00
Touati Djamel (otd) c82e9d036c [FIX] delivery: raise a UserError if the total weight is 0
Steps to reproduce the bug:
- Install `delivery_dhl`
- Create a storable product “P1”:
    - make sure the weight of the product is equal to 0
- create a transfert:
    - Type: delivery orders
    - Add the product “P1”
    - Go to “Additional info” tab and select “DHL” in the carrier field
    - Mark as Todo
    - Validate

Problem:
A traceback is triggered, because in order to set the shipment details,
a package should be created, so the `_get_packages_from_picking`
function is called:
https://github.com/odoo/enterprise/blob/aed802ee17dba5ebe12b42594503732a2662be68/delivery_dhl/models/dhl_request.py#L166

But as the total weight of the products is equal to 0, the package is
not created:

https://github.com/odoo/odoo/blob/6b0ab28791f4a29254d294f8a116545d4c124e8b/addons/delivery/models/delivery_carrier.py#L324-L325

then, the result is used without checking if the package has been
created:
https://github.com/odoo/enterprise/blob/aed802ee17dba5ebe12b42594503732a2662be68/delivery_dhl/models/dhl_request.py#L185

Solution:
If the total products weight is equal to 0, raise a UserError

opw-3076826
opw-3075562

closes odoo/odoo#106894

X-original-commit: c18064d717312287f5acba2fabeb77b2e1c01fb9
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-11-30 16:07:56 +01:00
Adrien Widart (awt) b603cde02d [FIX] delivery: hide useless length UoM
The dimensions UoM of the carrier packaging is useless: it is not the
one used in the requests and there is not any conversion

To reproduce the issue
(Need delivery_fedex. Use demo data. Enable debug mode)
1. In Shipping Methods, edit 'Fedex US':
    - Package Weight Unit: KG
    - Debug Requests: True
2. Edit its Fedex Package Type:
    - Height: 1m
    - Width: 1m
    - Length: 1m
    - Package Code: YOUR_PACKAGING
3. Create a SO with a US partner and one product
4. On the SO
    - Add Shipping
    - Select 'Fedex US'
    - Click on 'Get Rate'
5. In Logging, open the request sent

Error: the dimensions of the packaging are expressed with "CM" but they
are not converted:
```xml
<ns0:Dimensions>
	<ns0:Length>1</ns0:Length>
	<ns0:Width>1</ns0:Width>
	<ns0:Height>1</ns0:Height>
	<ns0:Units>CM</ns0:Units>
</ns0:Dimensions>
```

When encoding the packaging in the request, the UoM defined on the
packaging (meter) is ignored. Instead, we define a length UoM depending
on the UoM of the weight and we don't convert any dimension:
https://github.com/odoo/enterprise/blob/e4fd13a0e073b9855864b7fabc26bc05b9a5fd19/delivery_fedex/models/fedex_request.py#L172-L178
There is even a `TODO` about the issue.

It will be the same with the other carriers. For instance, with UPS:
https://github.com/odoo/enterprise/blob/c9899f7860cd19c86f215d6dcea89f73b51433f3/delivery_ups/models/ups_request.py#L98-L102
We use the UoM of `ups_package_dimension_unit` and do not convert the
dimensions.

We can't implement the dimensions conversion on stable versions, since
it will break all existing packagings. So, as temporary solution, we can
simply hide the useless UoM defined on the packagings.

OPW-3053048

closes odoo/odoo#106338

X-original-commit: 3bc2f594395a08515ed362e3d9a816e7cc18c842
Related: odoo/enterprise#34305
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2022-11-24 12:26:06 +01:00
niyasraphy 990ce0331b [FIX] delivery: show only delivery apps and translatable string
closes odoo/odoo#105726

X-original-commit: 9572e0a0410787ac60aeeb3996b4044f7d7eda22
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2022-11-15 10:34:15 +01:00
Chong Wang (cwg) b95b549d24 [IMP] core: raise warnings for related translated stored fields
The _compute_related function can only update one translation but not all. We
decide not to update all translations to avoid increasing the time complexity.
As a result, the value for related translated fields should always be generated
in the runtime, and storing it is illegal.

A related translated stored field may work as expected in a single language
environment. But in mult languages environment, if you have a name field

    name = fields.Char(related="parent_id.name", store=True)

changing parent_id in French, will only change the French translation of the
name field

This PR tries to remove these fields. And a warning is added to prevent
developers creating a related translated stored field in the future.

closes odoo/odoo#102553

Related: odoo/upgrade#4004
Signed-off-by: Wang Chong (cwg) <cwg@odoo.com>
2022-11-10 14:13:41 +01:00
Adrien Widart (awt) ef775df746 [FIX] delivery: add a carrier on a delivery
It is not possible for a user to add a carrier directly on a picking if
the invoicing policy of that carrier is set to "Real Cost"

To reproduce the issue:
1. Enable a carrier C
2. Setup a shipping method SM:
    - Carrier: C
    - Invoicing Policy: Real Cost
3. Create and confirm a SO with a product
4. Edit the related picking P:
    - Carrier: SM
5. Validate P

Error: a Validation error is raised "The operation cannot be completed
[...] Model: Sales Order Line (sale.order.line), Field: Description
(name)"

When validating the delivery, we try to create a new SOL with the
shipping cost. We then update its description with the carrier name.
However, since the carrier has been directly added on the picking, the
sale order does not have that information. We should rather get this
information from the delivery.

OPW-2862306

closes odoo/odoo#103986

X-original-commit: 611bd008075f5b8f8080281ae877ada3076a9e7a
Signed-off-by: Adrien Widart <awt@odoo.com>
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-10-25 09:26:00 +02:00
Laurent Desausoi 7593c073d2 [IMP] core: use inert SQL based neutralization
Before this commit the neutralize system introduced in v16 was using ORM
methods in order to change appropriate records. Although flexible, this approach
could lead to call some methods with side effects while neutralizing
(eg: overloads of write).

This patch converts the neutralize system to a safer "inert" SQL based approach
by migrating the generic method _neutralize to SQL files exposed in the
data folder.

Task id: 2961687

closes odoo/odoo#102792

X-original-commit: e5dbded9bb363351feff7ca8a56c7f8a6860f492
Related: odoo/enterprise#32580
Signed-off-by: Fabien Meghazi <fme@odoo.com>
2022-10-09 22:04:00 +02:00
Victor Feyens 4e2d7b800d [CLN] sale: rename _get_invoice_status
follow code guidelines and use _compute_invoice_status instead.

Part-of: odoo/odoo#98068
2022-09-01 19:16:48 +02:00
momegahed c004067287 [FIX] delivery: tax calculations are wrong on delivery products
Steps to reproduce:

1- install sale, accounting
2- create a fiscal position fp that maps
tax inc t1 to any other tax t2
3- create a delivery product dp with t1 and mark it "can be sold"
4- create a new delivery method with dp
5- in a new sales order, choose fp, click on add delivery
6- the unit_price is wrong, it hasn't mapped t1 to t2
7- try adding the delivery as a product in a new sales order line
8- the unit_price is correct and the taxes are correctly calculated

Bug:

 `_create_delivery_line` is not using the same logic used
 when normally adding a sales order line although technically
 delivery product is still a product

Fix:

use `_get_tax_included_unit_price` to get the correct unit_price

OPW-2806965

closes odoo/odoo#96874

X-original-commit: 03bb18d12606447faaed0de04bb83dde5de53b96
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Mohamed Megahed Abbas Megahed SALLAM (mome) <mome@odoo.com>
2022-08-01 10:55:34 +02:00
Miquel Raïch 02c541a73b [FIX] delivery: assure stock user can validate pickings
Steps to reproduce:

- Delivery module is installed.
- User_1 is stock_manager and sale_manager.
- User_1 creates sale_order with set carrier_id and confirms it
  (Automatically is created a picking P).
- User_2 is stock user/manager but in sale is "Own documents only".
- User_2 open picking P and validates it.
  => Error: cannot validate due to access rules.

closes odoo/odoo#94684

X-original-commit: 465bb47b89e34609b34a647a5a4ba4db8a0ffc8a
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2022-07-11 23:43:41 +02:00
Tiffany Chang (tic) 22fa7f90e4 [IMP] {website_}sale, delivery: add local delivery option
This commit does a couple of small related improvements:

- adds new delivery options: "Local Delivery".
  We replace the existing "Normal Delivery Charges" with the new "Local
  Delivery" since it is now redundant.
- Originally a "Local Pickup" demo option was going to be added, but
  this appeared redundant with the "[On Site Pick]" added in
  odoo/odoo#87636 . Regardless, an additional `carrier_description`
  field has been added so users can include extra instructions (e.g.
  address to pick up from, when pickup can occur, etc) to sales orders/
  confirmation emails (emails only via ecommerce sales).
- adds option to filter based on zip prefix rather than the previous zip
  "range" option, which was too restrictive in some cases (e.g. in the
  UK where zips can have letters in them). Note that users can view/edit
  zip prefixes in menu under settings when debug mode is active. Note:
  - prefixes are ordered by name so its easier to read large numbers
    prefixes
  - prefixes are always capitalized to avoid duplicate prefixes that
    differ by case + avoid capitalizing all prefixes every time the
    `_match_address` logic is called

Task: 2706451
Upgrade PR: odoo/upgrade#3384

closes odoo/odoo#84620

Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2022-06-29 14:44:19 +02:00
Ahmed Khalaf (ahkh) 0a6f0bb760 [FIX] delivery: commodity product country code
Commodity now uses product county of origin code instead of
country of origin field directly since its a res.country model
and breaks the request if set on a product

closes odoo/odoo#93195

X-original-commit: 980d103050fee552a9f68421cf119c119397bbe2
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2022-06-17 14:14:06 +02:00
Ahmed Khalaf(ahkh) 42714e2202 [IMP] delivery,stock: added pack type weight
Base Weight field added to Package type to be added to shipping weight

Task: 2764771
Part-of: odoo/odoo#91640
2022-06-03 12:02:05 +02:00
Raphael Collet 6cf8db906f [REF] *: adapt code to new flush API
closes odoo/odoo#87527

Related: odoo/upgrade#3497
Related: odoo/enterprise#26939
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-05-25 18:00:47 +02:00
Yolann Sabaux f9d6bda792 [FIX] delivery: wrong invoice status for partially delivered orders
Steps to reproduce:
- Select any two storable product that has invoicing policy set on 'Delivery'
- Create a sales order lines with these two products and make sure that one of the lines should have a quantity set to 0
- Add shipping

Issue:
- The Invoice Status has changed to 'To Invoice'

Solution:
Add en extra filter to consider only lines that have not been invoiced.

opw-2750861

closes odoo/odoo#89548

X-original-commit: bfeb5f6317786edfd0fa464fe5798c7f7bc65ac9
Signed-off-by: yosa-odoo <yosa@odoo.com>
2022-04-25 18:15:06 +02:00
anhe-odoo c225996bb0 [FIX] delivery: remove wrong currency conversion for delivery carrier price
Observed Behaviour

When using a pricelist with a fixed price for all products with a different
currency than the one of the company, adding shipping cost in a sale order
using this pricelist will give a wrong value of the shipping cost

Expect Behaviour

The computed shipping cost added in the sale order should be the same as the
fixed price defined in the pricelist

Reproducibility

This issue can be reproduced using the following steps :
1. Define a pricelist PL1 with a fixed price for all products and a different
currency than the one used in the company (eg fixed price to 15KR)
2. Create a sale order and select PL1 as pricelist
3. Add a product and add a shipping cost

The shipping cost should be the defined fixed price (15KR) but it gives
another value, depending of the company currency

Fix Description

This fix remove a useless currency conversion coming from the fact that since
https://github.com/odoo/odoo/pull/86484 we get the delivery price from the SO
priceliste (using  pricelist.get_product_price) giving us a price that  is
already converted to the correct currency

Related issue/PR

opw-2810506

closes odoo/odoo#88861

X-original-commit: 25e2f403e88172d67ea6ce382ac1e3f5e0e37835
Signed-off-by: Adrien Widart <awt@odoo.com>
Signed-off-by: Hendrickx Anthony (anhe) <anhe@odoo.com>
2022-04-15 11:31:59 +02:00
Goffin Simon a110ddc509 [FIX] delivery: Terms not translated in the partner lang
Missing translation

opw:2782254

closes odoo/odoo#87891

X-original-commit: 863537b927d3fa502385e03c58741efccd9e2545
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Simon Goffin <sig@odoo.com>
2022-04-14 12:01:47 +02:00
anhe-odoo bc27fffb27 [FIX] delivery: use pricelist to compute shipping cost
Expected Behaviour

When adding a shipping cost in a SO, with the shipping method being
associated to a product, the price should be calculated according to
the price of the product in the order's pricelist if available

Observed Behaviour

When adding a shipping cost related to a product, with a fixed price,
the public price of the product is used instead of the price defined
in the SO pricelist

Reproducibility

1. Create a product "Test Shipping" with a public price of 10
2. Create a shipping method "Test Shipping" associated with the
"Test Shipping" product
3. Create a pricelist "Test Pricelist", where the product "Test
Product" has a cost of 15
4. Create a contact "Test Contact" associated with "Test Pricelist"
5. Create a So for the "Test Contact" with "Test Shipping" as shipping
method -> Shipping cost will be 10 instead of 15.

Fix Description

The issue here was that the price computed by the delivery carrier didn't
took into account the selected pricelist. We tried to then change it in
the delivery chooser wizard, but some issue with particular case (i.e.
when the shipping cost should be 0 if the SO total is bigger than X)
appeared, leading us to add the fix directly in the delivery_carrier
classe.

Related Issues/PR

- opw-2754482

closes odoo/odoo#87028

X-original-commit: bb778cd7be835706f54e9e0f342eecf3e5e4e904
Signed-off-by: Adrien Widart <awt@odoo.com>
Signed-off-by: Hendrickx Anthony (anhe) <anhe@odoo.com>
2022-03-23 07:06:06 +01:00
boan-odoo 800501e679 [IMP] delivery: group product moves by carrier
In the "Reporting -> Product Moves" view,
allow grouping of products by carrier names.

Task: 2654703-2-2
Part-of: odoo/odoo#84056
2022-03-21 11:11:59 +01:00
Wolfgang TafernerandAndreas Perhab 2060efdcad [IMP] delivery: ease to inherit delivery currency computation
closes odoo/odoo#85946

X-original-commit: f4f833bb74ef0a73376d0e86e7350041b9074f36
Signed-off-by: Arnold Moyaux <arm@odoo.com>
Signed-off-by: Wolfgang Taferner <w.taferner@wtioit.at>
Co-authored-by: Andreas Perhab <andreas.perhab@wt-io-it.at>
2022-03-08 07:00:48 +00:00