Commit Graph
930 Commits
Author SHA1 Message Date
Nasreddin (bon) 3e1395b77e [FIX] sale: Traceback on update price (price list) and price = 0
Issue

	- Create a Price list and set 'Discount Policy' as
	  "Show public price & discount to the customer "
	- Create an SO
	- Add a multiple product with at least one with price unit = 0
	- Change the pricelist and update prices

Cause

	Division by zero when calculating discount.

Solution

	Calculate discount only if there is a price_unit.

opw-2393790

closes odoo/odoo#63218

X-original-commit: 9f70f405bc453ce56b75d22a318c9fd72e8bd496
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
2020-12-11 10:11:40 +00:00
Goffin Simon 57de89982a [FIX] sale: Optional product price
Steps to reproduce the bug:

- Let's consider a product P with sale UOM = Unit and unit price = 10€
- Create a SO and add a sale.order.option SOO with P and Dozen as UOM

Bug:

The unit price was 10€ instead of 120€

opw:2413237

closes odoo/odoo#62992

X-original-commit: 880555b38dee0c3e3b364c19bb6b0db983bf8aa0
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2020-12-08 09:10:08 +00:00
Adrian Torres 679185f3e8 [IMP] *: replace all raises inside unlink by api.ondelete
With this commit, all instances of errors being raised inside
`BaseModel.unlink` overrides are moved into methods decorated with
`api.ondelete` which is safer.
2020-12-04 09:16:16 +00:00
Victor Feyens e64f03c185 [IMP] *: restrict the deletion of used currencies 2020-11-27 16:10:01 +00:00
Victor Feyens ab76c421c2 [IMP] uom: protect/warn against uom changes/deletion
1) forbid deletion of main uoms & categories

2) warn modifications of main uoms data.
Except for the working Hours uom, which isn't a strict UoM
representation and could change between countries (and/or be deleted).

3) Also move the Dozen UoM to demo datas, it's a confusing UoM and isn't
used by the majority of databases.

4) Restrict deletion of used uoms on main models.
On sale orders and account moves the uoms couldn't be deleted thanks to the
SQL constraint covering the display_type logic, but the generic error message
is more clear for a user when deleting an uom.
2020-11-27 16:10:01 +00:00
Denis Roussel 788930d7d2 [FIX] sale: Wrong argument in untaxed_amount_to_invoice computation
closes odoo/odoo#62503

X-original-commit: 0ddad8128d3ea4ab75b98bea8da3c1de676c1b5d
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-11-27 10:31:00 +00:00
Goffin Simon f52b1655c1 [FIX] sale: Wrong lang in terms and conditions
Steps to reproduce the bug:

- Let's consider a configuration with two languages L1 and L2
- Go to Settings / Accounting / Customer Invoice / Default term & condition
- Define a default text T1 and save
- Create a new customer invoice, T1 is displayed in the field narration
- Go to Settings / Accounting / Customer Invoice / Default term & condition
- Change T1 to T2 for L1, L2 and save
- Create a new customer invoice

Bug:

T2 was displayed in the field narration

opw:2388353

closes odoo/odoo#62270

X-original-commit: 98d36b80ed1b4f11491301d3b7b5818d81edf542
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2020-11-24 16:47:32 +00:00
Ivan Yelizariev fe38009e8f [FIX] sale: fix custom values order in product description
STEPS:
* activate Product Configurator
* create 3 attributes with custom values option
* create a quotation with a product having all 3 attributes and custom values
* select the custom values for attributes in different orders for each SO line

BEFORE: Product description get random order for the custom attributes list

AFTER: Order is fine

---

opw-2379778

closes odoo/odoo#61869

X-original-commit: 57eb05071a08251171dcfdb2308feb13c3281fa7
Signed-off-by: Ivan Yelizariev // IEL <yelizariev@users.noreply.github.com>
2020-11-17 14:44:59 +00:00
Nicolas Galler f0232808c2 [FIX] sale, sales_team: fallback to partner's team
Behavior prior to the commit:

- when setting the customer (partner) on a sales order, the sales team
is set based on the partner's sales person.  If there is no sales person
on the partner then the team defaults to the first team in sequence for
the company.
- the team set on the partner is not used (by default, this field is not
visible, but it can be set from server action or added via studio).  In
Odoo 12.0 the team set on the partner was used as a fallback, but this
was removed in commit 242be00429

Behavior after the commit:

- the partner's team is used as fallback when the partner is updated
- when the salesperson is updated on the quote, we also use the current
team as fallback (since presumably this was set either from the partner,
or using the existing default rule, there is no reason to change it)
- in debug mode, the field `team_id` is shown on the partner view (under
the `Sales & Purchases` tab)

Note:
- Change in existing installation is expected to be minimal since it only
affects the customers who are making use of the partner.team_id field, not
populated or displayed by default, but there is a risk for a customer who:
   1. has that field populated on existing partners (maybe upgraded from
   an old install where it was displayed?)
   2. is relying on the new (as of v13.0) behavior of assigning the default
   sales team based on the sequence

opw-2351868

closes odoo/odoo#61827

X-original-commit: 7683e1907f6eb1fde4626927957df4eede49b8ca
Signed-off-by: Nicolas Galler <ngaller@users.noreply.github.com>
2020-11-17 09:49:35 +00:00
Andrea Grazioso (agr-odoo) c97e605457 [FIX] sale: keep card info on form save
Configure card payment provider (stripe, Authorize, etc) in test mode
Allow the customer to decide if saving payment info
Go to web shop, fill cart and checkout
Select provider and check "save payment method"

After payment the card info is not saved:
the related check variable is overridden in the process.

Note: this occur only when using the provider site.
S2S payment via Odoo follows a different flow

opw-2335237

closes odoo/odoo#61351

X-original-commit: dc18fdba1d4e0d38df0ebce4eed46f8ad08f4821
Related: odoo/enterprise#14597
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
2020-11-04 16:37:30 +00:00
Martin Trigaux b5ab4a3aca [FIX] sale: revert cfc9abe14689d
Revert "[FIX] sale: correct _get_to_invoice_qty depends"
This reverts commit cfc9abe14689db82acf1872fa8d358662fc7e123.

While the field is indeed in the list of records, it's a big change of
behaviour.
Retroactively changing the invoicable lines of sale.order that are
closed is dangerous and can lead on unexpected behaviours.
Performances can also be bad when changing the product configuration
on a database with a lot of sale orders.

Changing the product configuration should only apply to future orders,
not past.

closes odoo/odoo#61168

X-original-commit: be13bc94c2ff51b99a4399be44a765d0b28202eb
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-11-02 14:04:48 +00:00
Andrius Laukavičius 7f01ea640f [FIX] sale: correct _get_to_invoice_qty depends
`product_id.invoice_policy` dependency was missing.
When changing the policy from "delivery" to "order" of a product, the
quantity of invoiceable products was not recomputed and remained 0

Closes odoo/odoo#60674

closes odoo/odoo#61026

X-original-commit: cfc9abe14689db82acf1872fa8d358662fc7e123
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-10-30 08:45:10 +00:00
Nicolas Martinelli b5332aca63 [FIX] sale: group SO with section in single invoice
- Create SO 1:
  - Section A, sequence 10
  - Product A, sequence 11
- Create SO 2:
  - Section B, sequence 10
  - Product B, sequence 11
- Select both SO
- Create the invoice

The resulting invoice lines are organized as follow:
- Section A, sequence 10
- Section B, sequence 10
- Product A, sequence 11
- Product B, sequence 11

This is obviously not expected as it messes up the organization of the
lines.

This happens because the sequences of the SO lines are kept at invoice
creation, while it is necessary to resequence the invoice lines to keep
them organized.

To do so, we loop on the invoice lines before their creation in order to
assign a sequence corresponding to the order in which they have been
added in the list. Since the invoice lines are added one SO after the
other, this allows us to keep the appropriate ordering.

Note that we only resequence if there are less invoices to create than
SO, meaning that several SO have been merged. Indeed, in case a single
invoice is created from a single SO, there is no need to resequence.

This assumption is not completely true: if not all selected SO were
invoiceable, the number of invoices created is also smaller than the
number of SO. However, resequencing should be safe so in the worst case
we might resequence an invoice while it was not necessary.

We also leave the possibility for third-party addons to alter the
resequencing thanks to the `_get_invoice_line_sequence` method.

opw-2363443

closes odoo/odoo#60789

X-original-commit: 97c2f5ea51a669830b3e6d6d2d7d857742a41481
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-10-27 08:38:20 +00:00
Andrea Grazioso (agr-odoo) f55639dfac [FIX] website_sale_coupon_delivery,sale: validate taxcloud after carrier
change

Configure taxcloud, 2+ delivery carrier, card payment
Go to the website shop
Add product to cart
Checkout with USA address
On the Confirm Order page, the tax is computed via TaxCloud and shown on the right.
Pay via payment acquirer site

The Subtotal (without taxes) is sent to the Payment Acquirer instead of the Total

This occur because when selecting delivery carrier coupon lines are
recomputed. To be on the safe side with taxcloud, taxes are excluded before
recomputing coupon lines, but never added in this specific flow.

opw-2338103
opw-2362493
opw-2353048

closes odoo/odoo#60570

X-original-commit: f220e66d707654ee76dc343685dee8c2dda68dd5
Related: odoo/enterprise#14351
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-10-22 18:00:23 +00:00
jbw 05706dff88 [FIX] account, account_payment, sale : add support of new 'reversed' payment_state
Add handling of reversed payment state (added in odoo/enterprise#7202) in move view, portal templates and sales_team.

closes odoo/odoo#60139

X-original-commit: 2e1003a969f6fc907544e6506e1c6147e5e11d3e
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2020-10-15 20:22:55 +00:00
Andrea Grazioso (agr-odoo) 75e59aeff8 [FIX] sale: calculate untaxed_amount_to_invoice based on invoiced quantity
Enable discounts on sales order lines
Create a service type product with invoicing based on timesheet and
task in sales order's project
Create so for 6 hours and deliver 8 hours.
Create 2 invoices: One for 6 hours with the regular price and 2 hours
h 100% discount.
Invoice status of the order will be Fully Invoiced

Go to Sales>Reporting>Sales Analysis report will show the untaxed amount
associated with 2nd invoice as still to invoice which is incorrect

This occur because when saving the invoice the untaxed amount is
calculated on the amount invoice after discount

opw-2338564

closes odoo/odoo#59638

X-original-commit: be5ec58d0a1a71fc84ca790555cac02a6be5b67a
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-10-09 12:40:46 +00:00
Goffin Simon c40e20c496 [FIX] sale: Update pricelist when discount_policy = 'with_discount'
Steps to reproduce the bug:

- Let's consider two pricelist PL1 and PL2 with discount_policy = 'without_discount'
- Let's consider a product P
- PL1 has 10% on P and PL2 has 20% discount on P
- Create a quotation Q with PL1
- Add P on Q (the 10% discount is correctly applied)
- Change PL1 to PL2 and click on Update pricelist

Bug:

The 20% discount on P was not applied.

opw:2352577

closes odoo/odoo#59541

X-original-commit: 9f1280e275fd851fce17bf82c603fdc50a8ef94e
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2020-10-08 15:46:54 +00:00
Florent de Labarre 5721b035a7 [FIX] sale: use rounding of currency of order
closes odoo/odoo#59402

X-original-commit: 6c68a9b6af19ed1149b2a6651bce3ca5e36a6c8b
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2020-10-07 11:47:47 +00:00
Anh Thao Pham (pta) 68cf175e07 [FIX] sale: fix untaxed_amount_to_invoice field computation
- Go to Invoicing > Configuration > Taxes
- Create a Tax and enable "Included in Price" in Advanced Options tab
- Go to Sales and create a Quotation:
  * Add an Order Line with the created Tax
- Save & Confirm
- Edit the Quotation to set a delivery quantity, then save
- Go to Sales > Reporting > Sales:
  * Display row by "Order #"
  * In Measures, add "Untaxed Amount to Invoice"
- Check the values for the create SO
The amount for "Untaxed Amount to Invoice" is the amount with taxes included.

It is due to the fact that untaxed_amount_to_invoice field of sale.order.line is computed
from price_reduce field.
As price_reduce is computed from price_unit, if there is a tax that is included in the price,
price_reduce will also contain the tax in its value.

opw-2347571

closes odoo/odoo#59334

X-original-commit: 8c54ed42eef16817f198f10697820eddcc7d0c74
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
Signed-off-by: Anh Thao PHAM <kitan191@users.noreply.github.com>
2020-10-07 06:40:47 +00:00
Pierre Collinet (pic) 7b368e7215 [FIX] sale: Apply several fix on sales tour
1. Lead to loose the tour: Remove the step of the tour that asks
to set an address (the address is auto-completed at free trial
based on domain name).

2. Bug: At step 3, it redirects to the
invoice settings to select a localization, when you click on
"install more packages", you are sent back to the sales app.
--> this bug is related to res_config_settings.js from base addon.
I tried to fix this bug by adding a data-attribute "discard" in the
res_config_settings_views and checking this additional condition in
the js.

3. Bug: Tour blocks at last step "send by email" on quotation.
After clicking on "sent" on the pop-up, there should be rainbow
effect to mark the end of the tour.

4. Bug: Sale order line: fix the blue color on Invoiced Quantity
only, instead of the full line

5. Put the "sample product" in active= false (it's necessary for
the sample invoice but should not be visible to the user, they
should create their own)

6. Merge the 2 dates fields related to expected delivery on sale.order
--> since other modules extends this module, I made the field
expected_date invisible and put the same value in both fields. This
value is the max of the order_lines.expected_date

closes odoo/odoo#59261

Taskid: 2277314
X-original-commit: 0f81816d4ddb0febd28f6c6bb5dd50ae570333e1
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-10-06 11:57:55 +00:00
Arnaud Joset 9ace056714 [IMP] account,sale: html field for terms & conditions
Before this commit, the terms and conditions could not be html formatted text.

closes odoo/odoo#56512

Taskid: 2304199
Related: odoo/upgrade#1689
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-10-06 10:26:56 +00:00
nie 3765415e6a [FIX] sale: calendar view overrides stock picking name
Steps to reproduce the bug:
- Open the calendar view of the quotations in Sales
- Select a time slot and enter a summary (A)
- Click "Create", fill in the required values and add an order line
- Save and Confirm
- Click the "Delivery" smart button

Bug:
The delivery order has the summary (A) for name and not the computed sequence.

Cause:
Context key 'default_name' is added here:
https://github.com/odoo/odoo/blob/0db882ce3eddc88adb3e5046f9b8d14685ffc8a8/addons/web/static/src/js/views/calendar/calendar_controller.js#L231
And it's propagated up to here:
https://github.com/odoo/odoo/blob/0db882ce3eddc88adb3e5046f9b8d14685ffc8a8/addons/stock/models/stock_picking.py#L483

opw:2335541

closes odoo/odoo#59210

X-original-commit: df580bdc8fdaa33685862f2210881f19017f1daf
Signed-off-by: backspac <backspac@users.noreply.github.com>
2020-10-06 08:39:56 +00:00
Goffin Simon caa4ca7cc1 [FIX] sale, sale_prodcut_matrix: Default customer Lead Time not set with Order Grid Entry
Steps to reproduce the bug:

- Let's consider a product P with three variants red, yellow and blue
- Let's set a customer lead time on P = 10 days
- Set Order Grid Entry on P
- Create a quotation Q and add P
- In the grid entry matrix add 1 red, 1 yellow and 1 blue

Bug:

The customer lead time of these three variants were not set on the lines.

opw:2337049

closes odoo/odoo#58675

X-original-commit: 0eae213d6c8a656ab2c045995e1f0643ff65df51
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2020-09-28 12:45:08 +00:00
Luis González 45dce9ce00 [FIX] sale: Access error when user as accounting access but not sale
If an user that only has access to accounting but not to sale, tries to
validate an invoice created from a sale order, an access error will be
raised. That's because, when the invoice status changes, the invoiced
quantity on the related sale order is recomputed using the current user,
which may not have access to read sale order lines.

This commit fixes the above by ensuring the recomputation is performed
with superuser access rights.

closes odoo/odoo#58304

X-original-commit: 0bf30e1b5907997ae22d27cc420c3533940d634f
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-09-23 09:39:38 +00:00
Nicolas Martinelli 9d8ed8d001 [FIX] sale, sale_stock: expected date computation
- Create a SO
- Add a line with a lead time != 0, e.g. 7 days
  => the Expected Date is today + 7 days
- Add a note or a section on the SO

The Expected Date is today

This happens because we do not filter out notes and sections when
computing the minimum date.

opw-2340419

closes odoo/odoo#57792

X-original-commit: d3a6afe51fc4b864368acbc40a86ac6974d328dd
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-09-16 07:44:04 +00:00
Goffin Simon dba5a8388d [FIX] sale, sale_product_configurator: Quantity not copied from Configurator to Rental Wizard
Steps to reproduce the bug:

- Let's consider a rental product RP with variants
- Configure product configurator
- Create a rental order
- Select RP and set a quantity in the product configurator
- Click on Add

Bug:

When the rental.wizard was opened, the quantity was not taken into account and was reset
to 1.

opw:2321357

closes odoo/odoo#56913

X-original-commit: afe0f0d5566df9bccc28535e85dec98d3c7587b4
Related: odoo/enterprise#12871
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2020-09-02 07:52:54 +00:00
Goffin Simonandagr-odoo 4f10dfa527 [FIX] sale, sale_management: add tax on options (portal)
Steps to reproduce

Enable optional products in sale order
Make a sale order with optional products for a portal customer
with taxcloud fiscal position. Validate the order.
Tax will be calculated on the sol.

Access the sale order as the portal user.
Add the optional product, verify the order and pay.

The optional product will get the taxcloud data
AFTER the order has been verified and possibly paid. As this should not
occur this add the override to calculate taxcloud data right after
adding the optional product

opw-2310614

closes odoo/odoo#56110

X-original-commit: a7a91d5de55817b7580f3cd3d262a9dcce7496e7
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
Co-authored-by: agr-odoo <agr@odoo.com>
2020-08-24 16:11:12 +00:00
Dharmraj Jhala f49dbf595c [IMP] account, purchase, sale: allow sending email to self
Currently, if users try to send invoices / quotations / purchase orders to
themselves in order to look at final result, they can't do so because our
default chatter protection prevents sending mails to authors themselves.

This commit uses 'mail_notify_author' context key and allows users to send
mails from the header buttons available on SO / PO / invoices to themselves
if they are in recipients.

This commit targets only those buttons as this is the main case where we
want to allow people to send emails to themselves. In order to avoid
side effects no other use case is supported.

Task ID-2294130

closes odoo/odoo#56370

X-original-commit: 08c0dc929da38595e29a9d1db93065547cd98ad1
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-08-24 08:14:44 +00:00
sbejaoui fb1b88c893 [FIX] sale: update fiscal position on company change
closes odoo/odoo#56160

X-original-commit: ac9f8e85c56c7fa635cfe2e89341df54277537bb
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-08-19 15:22:21 +00:00
Raphael Collet 1f48130d2b [REF] core: _name_search() now returns a list of ids
This provides a better API to search for records by name without the
formatting part (`display_name`).

This also simplifies all the overridings of `_name_search` that no
longer need to call `name_get()`.  The call to `name_get()` is done in
method `name_search` in a generic way.
2020-08-18 13:02:41 +00:00
Rémy Voet (ryv) 57f805f71e [IMP] stock*,mrp*: Dates Refactor
- The deadline of MO generated via procurements is calculated differently.
Now, it doesn't take anymore in account the manufacturing_lead
of the company (Security Lead Time of MO). The computation of planned date remains unchanged.
- The date_expected fields was duplicated with the date fields
except when the move was done. Merge both fields.
The only information lost is: we can't know what was the
scheduled date before processing move (`state` == done).
Indeed, the date becomes the actual move processing datetime.
- The `date` in `stock.picking` field contained the time of
(purchase) order `date_order` (`purchase.order`).
This field is was wrongly used in the kanban view where we
expected to see date_planned instead. Also, the `_order` used
this date instead of date_planned too.
- The `delay_alert` is activate independently of stock rules.
Then it is now activate in all case.
- Remove the auto-reschedulting process of stock move via
the stock rule (`propagate_date` and `propagate_date_minimum_delta`).
Replace it by a automatic deadline date (`date_deadline`) propagation.
The deadline is the promise done to/by vendor/client (SO/PO)
then it is a readonly fields on picking/move and MO.
- Now the Scheduled date (`date`) of stock move is never propagate
and it is only related to the Scheduled date of
related document (MO or picking).
- Now when a move is created from procurement (sale),
`date_planned` = `date_deadline` - `security_lead`.
- The `delivery_date` of sale is no editable after confirmation
and propagate as the deadline to related stock move linked to order_line
- Adapt filter and decoration of MO and picking.
- Because we are the client in case of purchase (PO), the promise of vendor
can be not respected. Then we add the lead security to the deadline
(inverse the sale order logic) of PO picking (promise reciept date
+ security lead) to match with the replenishment.

task-2246665
2020-08-18 07:48:27 +00:00
Martin Trigaux 6156f98288 [FIX] *: adapt action content retrieval
Use _for_xml_id to replace all the self.env.ref().read()[0]
This has the advantage of having a single point of control and to add
the fields filtering and model verification.

Add sudo for other operations on ir.actions.*
2020-08-17 09:09:02 +00:00
Victor Feyens fdb23e282b [IMP] *: wrong any() usage
Replace wrong usages of any(list|recordset), by any(generator)
to speed up computations, avoiding list creations and/or looping twice on a recordset
for nothing.

any([generator]) => any(generator)
any(filtered) => any(generator)

closes odoo/odoo#55768

Related: odoo/enterprise#12360
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-08-14 09:56:10 +00:00
root 390c01a430 [FIX] sale: allow adding/modifying values in sale confirmation
closes odoo/odoo#55861

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-08-13 10:02:04 +00:00
william 82dc0cb7b9 [IMP] account: soft post entries in the future
Add an easy way to not post the entries in the future when calling
post() on it, but rather set it to be auto-posted at accounting date.
This is useful when we are creating a lot of entries in batch and some
might be in the future, some in the past, and we don't want to separate
that in two batch every time. (asset, accrual, transfer,... )
2020-08-05 11:57:10 +00:00
william 276ba8e90c [FIX] account: do not store account internal type on aml
It was removed here https://github.com/odoo/odoo/pull/32303 but readded
later. We still don't want it for the same reasons.
Having it on related (non stored) is enough.
2020-08-05 11:57:09 +00:00
Antoine Prieels 0c3fe8736d [IMP] point_of_sale: Product configurator
Configure products with create_variants = 'never' from the POS

closes odoo/odoo#54956

Taskid: 208205
Related: odoo/upgrade#1522
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
2020-07-30 13:08:24 +00:00
Victor Feyens cc665d51e8 [FIX] sale,purchase: do not enforce company at _prepare_* level.
By specifying the with_company at a higher level:
1) The risk of multi-company conflicts decreases
2) We allow customizations to use _prepare_* methods to potentially
create records in other companies when needed.

closes odoo/odoo#55192

X-original-commit: 33c767e1778d2b1fc83aaaea92c3c2aa008b9520
Related: odoo/enterprise#12105
Signed-off-by: Toufik Benjaa (tbe) <tbe@odoo.com>
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-07-30 10:20:31 +00:00
Victor Feyens e8893f84ab [IMP] *: translations improvements
Avoid concatenation of translated strings & raw values and/or other 
translated values, and use the new _ API (by providing the formatting 
values to ensure the fallback on the english terms in case of wrong 
translation).

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

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

closes odoo/odoo#54635

Related: odoo/enterprise#11925
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-07-23 12:13:19 +00:00
Damien Bouvy c547f12efb [FIX] sale: set and propagate payment type in payment flow
The payment.transaction type field allows filtering some potential
payment methods down the line of a transaction being created; e.g. if a
subscription product is present in a quote, the payment's type should be
`form_save` to save the payment token for future use on the subscription
that will be created at confirmation.

The transaction that got created by sale flows did not set the type of
the transaction correctly, and this value was not propagated to the
rendering values of the acquirer. It now is.

This is necessary as part of task 2275051, where we need to know which
payment methods to enable in Stripe depending on a need for tokenization
or not (since some methods are not tokenizable).

closes odoo/odoo#54426

X-original-commit: 09dbbd77d83332c48f62b1c36c3b33ddbfa3a4eb
Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
2020-07-14 09:32:57 +00:00
Martin Trigaux 400cc4f14e [FIX] *: correct all or improve code translation lookup
This commit fixes all issues detected by the new pylint
gettext-variable test.
It converts some calls to the new syntax
  _("Foo %s", bar)

to progressively migrate the code to the new syntax.

A few calls were not technically incorrect but still detected by the
linter.

  _("Foo" +
    "Bar")

has been converted to

  _("Foo"
    "Bar")

as it has the same effect and make sure the argument is of type
asteroid.Const instead of BinOp).

closes odoo/odoo#53683

Related: odoo/enterprise#11467
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-06-30 10:19:59 +00:00
Nasreddin (bon) 499a649b16 [FIX] sale: Duplicating a Sales Order with Custom Attributes
Issue

	- Turn on Sales Product Configurator
	- Create a product template with an attribute and an attribute value defined as "is custom".
	- Create a new quote, add the template, and configure the product, entering a custom value.
	- Save.
	- Duplicate the Quote

	Custom value missing.

Cause

	Custom value (field product_custom_attribute_value_ids) not duplicated.

Solution

	Add attribute 'copy=True' to field product_custom_attribute_value_ids.

opw-2279933

closes odoo/odoo#53827

X-original-commit: 0ca092361819bb198c87ca6772ec0e93a2158018
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
2020-06-29 15:37:29 +00:00
Xavier Morel 6bd8e89766 [IMP] sale: avoid using _write to schedule an activity from the invoice status
Task 2186312

closes odoo/odoo#53427

Related: odoo/enterprise#11335
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-06-24 10:27:26 +00:00
Odoo's Mergebot e617aa91c5 [MERGE] tools: better placeholder support for _
Support two new syntaxes with `_()` method:

_("This is so %s") % 2019
_("Text with %s placeholders", 42)
_("Text with %(num)s placeholders %(symbol)s", num=42, symbol="🧀")

The main benefit is to have a fallback on the source string if formating the
translated string fails (e.g. "Foo %s" translated "Foo s%").

This PR converted most (but not all) calls to _ using placeholders to use the
new syntax. Hopefully, the remaining ones will be converted in the future and
avoid technical debt.

Use named placeholders when needed. If more than one placeholder is present in a
string, using named placeholder can be beneficial to reorder the placehodler
position (for languages like Japanese that do not use the same phrase
construction). On some sentences, it also brings clarity on the meaning of the
placeholders.

closes odoo/odoo#52155

Task-id: 1853119
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-06-18 13:51:48 +02:00
Martin Trigaux 80e97e98ce [IMP] *: use named placeholders in translated message
When more than one parameter is present in a message, it helps the
translation to use named placeholder. This way, the order can be
changed. It also helps the comprehension of the message.
2020-06-18 13:03:34 +02:00
Martin Trigaux ba244cef01 [IMP] *: replace to new _() syntax
Using a few regex like
\((_\(.*%s.*)(\) % )([\w\[\]][\w .\[\]\(\)'"]*)\)
($1, $3))

Old syntax is still compatible but starts the migration to the new
syntax that catches error.
2020-06-18 13:03:34 +02:00
jvm-odoo cb7a7deec5 [FIX] sale: fix no_variant price extra context propagation
Issue

	- Install Sales
	- Enable discounts & pricelists
	- Create a product
		- 2 variants:
			- first with "create variant" set to Always
			- second set to Never
	- Create a SO
	- Pricelist setting "without_discount"
	- Add the product with product configurator

	The line price is not correct (only Always taken in account)

Cause

	When the variant has Create Variant set to Never
	we pass the extra money in the context.

	When we have a pricelist with "without_discount"
	this context is not propagated correctly and it's lost

Solution

	Pass the product directly if it's not empty which
	have the context set.

OPW-2246102

closes odoo/odoo#53216

X-original-commit: 68628206c5883adc614045706fcc2ea085efd252
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
2020-06-18 09:28:09 +00:00
Andrea Grazioso (agr-odoo) dc1bb36d37 [FIX] sale: delete draft invoices with downpayments
Create a SO, Validate it.
Create Invoice: down payment (fixed amount) and validate invoice
Now back to the SO. Create Invoice: Invoiceable lines (deduct down payments).
A draft invoice is created. Try to delete it.

User gets an error, this occur because the second invoice creation bind
another invoice_line to the downpayment sale order line (first line was
added when making the downpayment). When the user delete the invoice
the sale order line should be deleted as well, but is still linked to an
invoice so the error raise.
Unlinking only unbinded sol fix the issue

opw-2258218

closes odoo/odoo#53144

X-original-commit: 7c7275b8a943196975182a8e66cef0e82f87b21d
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-06-17 10:28:26 +00:00
Adrien Horgnies a58458fb56 [FIX] sale: set payment type to form
current expression implies that any payment of a quote from the portal (/my/quotes) will try to save a token whenever the user says they want the customer to pay online, which seems bizarre. Normally you'd only want that for quotes with subscription products, and there is an override of that method in sale_subscription for that specific case.

closes odoo/odoo#53024

X-original-commit: 47f7230cd38c4e5a2f644a04f87fa0b5a844f73b
Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
2020-06-16 08:48:00 +00:00
Nicolas Lempereur b4b0828e25 [FIX] sale: have online salesperson default working
A sales order on the website will have as salesperson:

- the contact salesperson, and if not set

But if it's not a new address, the "Online orders" > "Salesperson" is
not used.

With this changeset, the "Online orders" > "Salesperson" is used by
default if there is no salesperson on the partner as was the intention.

opw-2274665
closes #52933

closes odoo/odoo#52939

X-original-commit: 957361a5c44b3797318657ce2486a3eff2a3f651
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-06-12 17:29:03 +00:00