Commit Graph
671 Commits
Author SHA1 Message Date
Adrien Widart 38a3f7fea4 [FIX] {purchase_}stock, product: base product name on supplier
Suppose a product with several suppliers, all with the same partner. On
the purchase order, the product description will always be based on the
last supplier

To reproduce the issue:
1. Create a vendor V
2. Create a product P:
    - Type: Storable
    - In Purchase, add a line L01:
        - Vendor: V
        - Vendor Product Name: Name01
        - Vendor Product Code: C01
        - Quantity: 1
        - Price: 10
    - In Purchase, add a second line L02:
        - Vendor: V
        - Vendor Product Name: Name02
        - Vendor Product Code: C02
        - Quantity: 20
        - Price: 2
    - Once P is saved, ensure the lines order in the purchase tab:
        - L01
        - L02
3. Add a reordering rule on P:
    - Min: 1
4. Run the scheduler
5. Open the generated PO

Error: The description is incorrect ("[C02] Name02" instead of "[C01]
Name01")

When computing the display name of the product,
https://github.com/odoo/odoo/blob/7691567286869ca65e63fc79c2cee11e1f415fcb/odoo/models.py#L1728-L1730
`name_get` returns a tuples list: `[(37, '[C01] Name01'), (37, '[C02]
Name02')]` where `37` is the product identifier. This list is then
converted into a dictionary and here is the issue: it will use the last
tuple to define the value for key `37`, i.e. "[C02] Name02". Therefore,
`name_get` should return the correct name, and only this one.

Another issue could be highlighted: when the user changes the quantity
of the purchase order line, if another supplier info is selected, the
description won't be updated (for the same reason as above)

OPW-2702616

closes odoo/odoo#82321

X-original-commit: a42608214f2e9ef3f5e59b4b54cd7f72a6019e06
Signed-off-by: Tiffany Chang <tic@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-01-06 19:30:49 +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
lathuat1997 f37d609bf9 [IMP]purchase: Format currency on the dashboard of Purchase List View
closes odoo/odoo#81535

X-original-commit: 33c7e5df6ca5aae4e53b5f3ae954a69820da3e20
Signed-off-by: Tiffany Chang <tic@odoo.com>
2021-12-16 15:57:47 +00:00
Yannick TivisseandVictor Feyens 18952cdc76 [IMP] *: Convert single create method into multi
Taskid: 2703085
Part-of: odoo/odoo#80824
Co-authored-by: Victor Feyens <vfe@odoo.com>
2021-12-14 19:13:18 +00:00
Yannick Tivisse f9f68adb2c [IMP] sale: Convert onchange_user_id into a compute method 2021-12-02 12:12:01 +01:00
Yannick Tivisse b9194406ec [IMP] account: Avoid multiple rebrowse in get_fiscal_position
+ Make it private, as it is not supposed to be called from the
webclient.
2021-12-02 12:12:01 +01:00
Goffin Simon 773583b17b [FIX] account,purchase: do not override analytic values
Editable computed fields need to have their own compute
method.

Otherwise, when providing one of the two fields at create/write time
will not be taken into account because the compute method will be
triggered for the other field.

closes odoo/odoo#77912

X-original-commit: e35dc4c87821bbb668657eed99bb51c1f853c208
Related: odoo/enterprise#21685
Signed-off-by: William André (wan) <wan@odoo.com>
2021-11-18 10:54:03 +00:00
Thibault Delavallée f9dbd38720 [IMP] mail, various: rename custom_layout / notif_layout context usage
RATIONALE

Currently we can specify email used for notification layouting through context
use in mail composer. It is then propagated to message_post, stored on
mail.message and used to encapsulate emails sent based on posted messages.

SPECIFICATIONS

On template model: rename ``notif_layout`` parameter of ``send_mail`` to
``email_layout_xmlid`` to be coherent with naming used in other parts of the
code. Moreover it better indicates we expect an xml id.

On rating model: rename ``notif_layout`` parameter of ``rating_send_request``
to ``email_layout_xmlid``, for the same reasons as above.

In various wizards: support ``email_layout_xmlid`` context key when no field
is available, notably because this is still done manually in some wizards
like survey invite. Keep a fallback on ``notif_layout`` but remove support of
``custom_layout`` deprecated since quite a long time.

Task-2621326 (Mail: add 'view' button in 'light notification template')
Task-2647302 (Mail: add layout field in composer)

Part-of: odoo/odoo#76418
2021-11-10 09:58:09 +00:00
Thibault Delavallée 3659546738 [IMP] mail, various: support email notification xmlid at model level in composer
RATIONALE

Currently we can specify email used for notification layouting through context
use in mail composer. It is then propagated to message_post, stored on
mail.message and used to encapsulate emails sent based on posted messages.

SPECIFICATIONS

Get rid of context usage (``custom_layout``) and use a real field on composer
model: ``email_layout_xmlid``. Use now a default value coming from context
(default_email_layout_xmlid) instead of custom_layout.

Support old context key in composer for backward compatibility, working like
a default value for the field itself.

Task-2621326 (Mail: add 'view' button in 'light notification template')
Task-2647302 (Mail: add layout field in composer)
UPG odoo/upgrade#2829

Part-of: odoo/odoo#76418
2021-11-10 09:58:09 +00:00
clesgow aefd5f7d64 [FIX] purchase: Don't plan PO line at the middle of the day
No longer converts the date_planned of a purchase_order_line to the
middle of the day. In case of multi-steps receipts, this caused a
discrepancy between the actual receipt and the later internal transfers.

Let's say a reordering rule is triggered :
- The date is set to midnight for the procurement, so the internal
transfer's date is set to midnight as well.
- The date is increased to noon for the PO line, which define the PO
planned_date, which define the linked receipt picking.
- So in the end :
  - Receipt is planned to day X at noon.
  - Transfer from Input -> Stock is planned to day X at midnight.

Task-2656397

closes odoo/odoo#79523

Signed-off-by: Arnold Moyaux <arm@odoo.com>
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2021-11-09 14:46:14 +00:00
clesgow 678bc958fa [IMP] purchase: Add purchase history for PO line
Sometimes it's difficult to track the price of a product, with the
different discounts you can obtain.
Price of products might change often and it's very practical to track
the price at the moment of the order to verify that it's in line with
what you paid in the past.

Also hides the Forecast Report button when a new line is created (and
not yet saved) as the button is disabled anyway without any feedback).
New purchase history button will also hide at creation.

Task-2658786

closes odoo/odoo#78438

Signed-off-by: Tiffany Chang <tic@odoo.com>
2021-10-29 13:22:38 +00:00
oco-odoo 9a80e2fa47 [FIX] purchase, sale: filter taxes properly when using a foreign VAT fiscal position
Before, when a foreign VAT fiscal position was used on a purchase order or sale order, no filtering was applied on the available taxes. We now make their behavior consistent with the invoices'.

Part-of: odoo/odoo#79144
2021-10-28 14:37:43 +00:00
Swapnesh Shah 0fed1ba061 [FIX] purchase: reset reminder status on cancel
Steps to reproduce:

* Create PO
* Confirm Receipt Date
* Cancel PO
* Draft and Confirm again

Current behavior:

* Button for Confirm Receipt Date is not visible

Expected behavior:

* Button for Confirm Receipt Date should be visible

This is happening as we are not resetting the value of `mail_reminder_confirmed` on cancelling PO.

With this commit, we reset value of `mail_reminder_confirmed` so use can Confirm Receipt Date again.

closes odoo/odoo#79122

X-original-commit: 9e48afe5bf4f52b7cc2705fe434b4647df752a59
Signed-off-by: Arnold Moyaux <arm@odoo.com>
2021-10-28 11:35:01 +00:00
William Henrotin f3fe2d50d9 [REF] *: rename name into partner_id on supplierinfo
Task: 2673000
Part-of: odoo/odoo#78732
2021-10-27 15:48:51 +00:00
Alvaro Fuentes ad9c67a1e2 [FIX] purchase: fix MemoryError when there are lots of line_ids
It seems that this long dereference causes a MemoryError for accounts
with many associated line_ids
```
select count(*) from account_analytic_account a join account_analytic_line l on l.account_id = a.id join account_move_line ml on ml.id = l.move_id where a.id=7
+---------+
| count   |
|---------|
| 131672  |
+---------+
```
The solution we propose is to use search_read inverting the order of
dereferences.

Shortened Traceback:
```
 Traceback (most recent call last):
 ...
   File "/home/odoo/src/odoo/15.0/addons/mail/models/mail_thread.py", line 410, in _compute_field_value
    return super()._compute_field_value(field)
   File "/home/odoo/src/odoo/15.0/odoo/models.py", line 4249, in _compute_field_value
    getattr(self, field.compute)()
   File "/home/odoo/src/odoo/15.0/addons/purchase/models/analytic_account.py", line 15, in _compute_purchase_order_count
    account.purchase_order_count = len(account.line_ids.move_id.purchase_order_id)
...
   File "/home/odoo/src/odoo/15.0/odoo/api.py", line 893, in update
    field_cache.update(zip(records._ids, values))
 MemoryError
```

Observed during the upgrade of 41031

We can reproduce this pref issue locally.
On the menu Accounting > Configuration > Analytic Accounting > Analytic Accounts, with 1 million account moves
```
test_15.0=> select account_id,count(*) from account_analytic_line group by account_id
+--------------+---------+
| account_id   | count   |
|--------------+---------|
| 1            | 1000002 |
+--------------+---------+
```
We get (shortened):
```
2021-10-19 07:39:33,807 53565 INFO test_15.0 werkzeug: 127.0.0.1 - - [19/Oct/2021 07:39:33] "POST /longpolling/poll HTTP/1.1" 200 - 9 0.077 50.063
2021-10-19 07:39:33,888 53565 INFO test_15.0 werkzeug: 127.0.0.1 - - [19/Oct/2021 07:39:33] "POST /longpolling/im_status HTTP/1.1" 200 - 4 0.038 0.044
2021-10-19 07:40:05,916 53565 WARNING test_15.0 odoo.service.server: Thread <Thread(odoo.service.http.request.140269940897536, started 140269940897536)> virtual real time limit (178/120s) reached.
2021-10-19 07:40:05,921 53565 INFO test_15.0 odoo.service.server: Dumping stacktrace of limit exceeding threads before reloading
2021-10-19 07:40:06,296 53565 INFO test_15.0 odoo.tools.misc:
File: "/usr/lib/python3.8/threading.py", line 890, in _bootstrap
...
File: "/home/odoo/src/odoo/15.0/addons/mail/models/mail_thread.py", line 410, in _compute_field_value
  return super()._compute_field_value(field)
File: "/home/odoo/src/odoo/15.0/odoo/models.py", line 4249, in _compute_field_value
  getattr(self, field.compute)()
File: "/home/odoo/src/odoo/15.0/addons/purchase/models/analytic_account.py", line 15, in _compute_purchase_order_count
  account.purchase_order_count = len(account.line_ids.move_id.purchase_order_id)
File: "/home/odoo/src/odoo/15.0/odoo/fields.py", line 2605, in __get__
  return self.mapped(records)
File: "/home/odoo/src/odoo/15.0/odoo/fields.py", line 1176, in mapped
  self.__get__(first(remaining), type(remaining))
File: "/home/odoo/src/odoo/15.0/odoo/fields.py", line 2603, in __get__
  return super().__get__(records, owner)
File: "/home/odoo/src/odoo/15.0/odoo/fields.py", line 1081, in __get__
  recs = record._in_cache_without(self)
File: "/home/odoo/src/odoo/15.0/odoo/models.py", line 5901, in _in_cache_without
  return self.browse(ids)
File: "/home/odoo/src/odoo/15.0/odoo/models.py", line 5149, in browse
  ids = tuple(ids)
File: "/home/odoo/src/odoo/15.0/odoo/api.py", line 952, in get_missing_ids
  if record_id not in field_cache:
```

closes odoo/odoo#78615

X-original-commit: 6077c9358fe650bcdc23e8d6a9432f639fca1b40
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-10-19 12:02:25 +00:00
Rémy Voet (ryv) e8d2920d9f [REF] stock*,purchase,mrp: used groupby of odoo
Instead of using sort + groupby of itertools (which group only
consecutive), use only the groupby of odoo.tools which
decrease the complexity of the code and avoid unmatched keys
between sort keys and groupby keys

task-2648449

Part-of: odoo/odoo#76761
2021-09-27 16:55:58 +00:00
wan fa034b2a64 [IMP] *: product back2basics 15.0
Rework the whole view, generally.

task-2605931

Part-of: odoo/odoo#75862
2021-09-07 15:50:00 +00:00
qdp-odoo 2dcbe92d78 [IMP] sale_stock, sale_timesheet, purchase_stock: accrual wizard now propose an amount taking care of the accrual date
This allows to solve the following use case:
* we are in March
* a SO created during January shows currently a delivered quantity (timesheet on service or delivered goods on storable products): timesheets/pickings were done in February
* creating the accrued entry for January 31 should display accordingly an amount of 0 by default since everything was done in February
Invoices invoice_dates are also taken into account:
* day 0 : delivered 10
* day 2 : 5 invoiced
* accrued entries for 10 if accrual date = day 1, accrued entries for 5 if accrual date = day 3,

followup of task 2255642

closes odoo/odoo#75886

Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
2021-09-02 15:36:50 +00:00
oco-odoo d9a3b938fe [IMP] account, sale, purchase, l10n_latam, l10n_ar: add the possibility to use subtotals above tax groups when displaying them
A new field on tax groups makes it now possible for this group to be displayed under a subtotal label. If not set, this defaults instead to "Untaxed Amount", keeping the traditional behavior. This is intended for withholding taxes, which can now be implemented with negative taxes and a tax group with this field set.

To do that, this commit entirely refactors the way amount_by_group worked, and replaces it with a more complete json field called tax_totals_json. It also streamlines the way taxe totals are displayed on invoices, PO and SO and makes it so that a common code is called instead of copy-pasting the same block 3 times as before.

[IMP] purchase: always display tax totals by groups on purchases orders

Before, tax totals on purchase.order's form were not shown by group, and were instead all aggregated in a single "Taxes" category. The same went for the pdf export. The portal view, though, did show the totals by group. We now display the tax groups in the same way all the time.

closes odoo/odoo#74138

Task: 2457374
Related: odoo/enterprise#19802
Related: odoo/upgrade#2670
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
2021-09-02 14:15:13 +00:00
JF Aubert 972ce4e445 [FIX] purchase: fix typo for dest_address_id label
Task: 2444742
Part-of: odoo/odoo#71732
2021-09-02 10:41:46 +00:00
Quentin Wolfs a9ba716510 [IMP] purchase: display proper state for PO in error
The raised error currently displays the internal state (e.g. 'purchase'
instead of 'Purchase Order') and therefore is not translated.

Task-2428819

Part-of: odoo/odoo#74364
2021-08-31 23:35:16 +00:00
yhu-odoo 45912aaebd [IMP] analytic, project, *: Improve views
Improve the views of analytic.account and project.project.
Add category to analytic.line.

Task-2469742
PR #68708
2021-08-27 16:40:49 +00:00
Thibault Delavallée e9af609616 [IMP] mail, various: reorganize and lint composer action name
In this commit some reorganization is performed within mail compose message
code. Purpose is to reorder a bit methods by main usage: onchange, CRUD,
actions, values generation with rendering and template management.

Some renaming is performed on action methods, notably send_mail that has some
impact on sub-addons. Finally we also set onchange and sub-onchange methods
private.

No functional change should be implied by this commit.

LINKS

Task ID-2377974
Community PR odoo/odoo#61467
Enterprise PR odoo/enterprise#14633
2021-08-18 13:35:07 +00:00
Martin Trigaux 15692f3948 [IMP] *: merge ir.model.data helpers
remove _get_id and _get_object_reference that were one liner to
_xmlid_lookup
2021-08-10 13:49:05 +02:00
Martin Trigaux c7bac3dee0 [IMP] *: make ir.model.data helper private
No reason to interfact with them directly in RPC
2021-08-10 13:49:04 +02:00
Adrien Widart fdd4af3e2a [FIX] purchase: use Product Price precision in bills
When the Product Price precision is greater than the currency precision,
it can lead to incorrect data

To reproduce the error:
(Enable debug mode)
1. Settings > Technical > Database Structure > Decimal Accuracy, edit
Product Price:
    - Digits: 3
2. Create a PO
    - Add a product:
        - Quantity: 12
        - Unit Price: 0.001
3. Save, Confirm, Edit the PO:
    - Qty Received: 12
    - (Note that the total is $0.01)
4. Create a bill:
    - Add the PO to the field "Auto-Complete"

Error: The unit price is $0.000 and so does the total

The rounding of the unit price should be based on the Product Price
precision, not the currency precision.

OPW-2601867

closes odoo/odoo#74813

X-original-commit: 1123856c77cce4b69059b63c2bcbb382c7f0719e
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-08-06 13:00:24 +00:00
Nasreddin Boulif (bon) 7df349883d [FIX] account: Fallback on self.env.user language if not user_id on PO
Steps to reproduce:

  - Install purchase and accounting apps
  - Set the database to a language that is not English
  - Create a purchase order
  - Remove purchase representative from PO (otherwise, no issue)
  - Action -> Create Vendor Bill
  - From the vendor bill, print invoice

Issue:

  The pdf is in English (country names, date labels, etc...)

Cause:

  If invoice type is `in_invoice` or `in_refund`, it will use the
  `invoice_user_id` language (object.invoice_user_id.sudo().lang).
  In the above case, there is no invoice_user_id on invoice.

Solution:

  While preparing invoice values, set invoice_user_id to
  self.env.user.id if not user_id on PO.

opw-2510134

closes odoo/odoo#74671

X-original-commit: 4b7569ce641a6fb20d5df676bf0b315d9b9d485d
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
2021-08-03 18:00:53 +00:00
Swapnesh Shah 97521cc0b2 [FIX] purchase: fallabck to default currency
Steps to Reproduce Bug:

- Create PO
- Remove default Currency
- Add a Line

Bug:
```ValueError: Expected singleton: res.currency()```

With this Commit, we are using default currency to round amount.

closes odoo/odoo#74234

X-original-commit: d9ff2e8ec7200aa15830e92e5083251c4e81dd1c
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-07-26 11:55:12 +00:00
Florent de Labarre a87c89d4ab [FIX] various: respect mail_post_autofollow previous values when adding it
Purpose of this commit is to avoid forcing mail_post_autofollow to True when
it is set to False. It eases inheritance and custom behavior.

Task-2612911
PR odoo/odoo#60792
2021-07-27 13:34:22 +00:00
Adrien Widart 997086ba5f [FIX] purchase: auto-complete bill with multi-currency
When adding several PO to a bill, if they don't have the same currency,
it will lead to incorrect amounts

To reproduce the error:
1. In Settings, enable "Multi-Currencies"
2. Invoicing > Configuration > Currencies:
    - EUR: Active, Current Rate = 2
    - USD: Active, Current Rate = 1
3. Create a PO:
    - Currency: USD
    - Products:
        - One product, no taxes, unit price 1000
4. Confirm PO
5. Edit PO:
    - Qty Received: 1
6. Repeat 3 -> 5 with EUR instead of USD
7. Open a new Bill
8. Add the first PO to the field "Auto-Complete"
9. Add the second PO to the field "Auto-Complete"

Error: Both invoice lines are now expressed in EUR and both subtotals
are equal to 1000 even though the exchange rate isn't 1

This commit suggests not to change the currency of the account move if
the latter already has some AML. Moreover, the amounts must be converted
if they come from a PO that uses another currency

OPW-2573748

closes odoo/odoo#73483

X-original-commit: b299e880417026688b2fbde23307bd011de8c44d
Signed-off-by: Steve Van Essche <svs-odoo@users.noreply.github.com>
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-07-09 10:11:42 +00:00
Rémy Voet (ryv) c19ac9e30a [FIX] purchase: fix forbidden access of partner
Issue:
For purchase user, which doesn't have the "Contact Creation" can't
create a purchase, get a AccessError.

The fields `receipt_reminder_email` and `reminder_date_before_receipt`
should be writable also for purchase user which doesn't have access
to write and create `res.partner`.

close odoo/odoo#64135

closes odoo/odoo#73131

X-original-commit: f29b1e81e6adf8532ecf90f9ecb675ec56eb4c61
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-07-02 10:27:23 +00:00
Victor Feyens 2e3dac8da0 [IMP] *: do not filter the taxes twice for nothing
Since _filter_included_tax_company filters the taxes of other companies,
there is no need to give taxes from other companies if the filtering was
already done.

closes odoo/odoo#71591

Related: odoo/enterprise#18670
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2021-06-17 12:14:36 +00:00
Victor Feyens 2d43dc2afd [IMP] account,*: clean map_tax definition
product and partner parameters are leftovers of an older definition of
map_tax, and can now be safely removed.
2021-06-17 12:14:36 +00:00
Adrien Widart c1f97a367f [FIX] purchase: compute unit price with different uom
On a product form, if the purchase UoM is different from the default
UoM, this will lead to an error when creating a RfQ.

To reproduce the error:
(Need stock)
1. In Settings, enable "Unit of Measures"
2. Create a product P:
    - Cost: 100
    - UoM: Units
    - Purchase UoM: Dozens
3. Create a RfQ:
    - Add P

Error: The quantity is 1 and UoM is Dozens, however the unit price is
$14400. The ratio has been applied twice.

When setting the product, an onchange method computes the unit price.
However, the computation is wrong: it first converts the product's
standard price using the purchase UoM of the product. Then, it converts
the result, this time using the UoM of the PO line.

OPW-2519294

closes odoo/odoo#72139

X-original-commit: b37a13d7763e4a69695fdb1567dce5d0f69ff78a
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-06-14 14:38:43 +00:00
Adrien Widart 07aa40d5b5 [FIX] purchase: send email on RFQ confirmation
When confirming a RfQ, even if a follower is subscribed to "RFQ
Confirmed", he will not receive any email.

To reproduce the error:
(Need a mail catcher)
1. Create a PO
2. Add a follower and edit his subscriptions:
    - Check 'RFQ Confirmed'
3. Confirm the PO
Error: No mail has been sent. The user should have been subscribed to
"RFQ Approved" to receive an email.

OPW-2447234

closes odoo/odoo#71892

X-original-commit: b459fc86d895dcd0c4bab8bb8332241fe9a43a6f
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-06-08 16:52:08 +00:00
dht-odoo c65289306e [IMP] purchase: improves field type from text to html
Replace text fields to html fields as we have our own 'OdooEditor'.
Indeed, it gives more options to users in the way they format their
content without weighting too much on the UI
(tools appear on demand and not by default).

Models -> Fields

1) purchase.order -> notes
2) purchase.requisition -> description

Task Id: 2499504

X-original-commit: 43958eff2b9346420104002d628d5ca9225f8090
2021-06-07 05:24:08 +00:00
yhu-odoo 688d655305 [IMP] {purchase, sale}_stock, product: packaging revamp
1. add packaging to PO lines
2. packaging on PO/SO lines can be propagate to MO
3. add package type to packaging
4. on picking types, we can choose to only reserve full packaging. That
means if you want 1 pallet(100 units) and you have 50 units in stock. It
won't be reserved.
5. suggest suitable packaging for PO/SO/MO line according to the product
qty

Task-2357259
PR #68654
UPG PR odoo/upgrade#2444
2021-05-06 13:36:28 +00:00
Xavier Morel b9f016f6c6 [FIX] *: markupify python content
Will require a lot more conversions for this to work..
2021-04-29 05:34:20 +00:00
Achraf (abz) 832125bd8c [FIX] purchase: Update correctly the price according to UoM
What are the steps to reproduce your issue ?

    1. Create Product with Purchase Vendor(s) set
    2. Create Units of Measure that are bigger than (10kg/50kg in tests)

What is currently happening ?

    If you put a vendor that is listed in product form, when changing purchase unit from kg to 10/50kg price is updated
    If you put a vendor not listed, it gives cost price which is correct, but does not update price according to unit of measure.

What are you expecting to happen ?

    Update correctly the unit of measure when the vendor is not listed

opw-2494769

closes odoo/odoo#69196

X-original-commit: d531e8a5e4d84fe6daa9110d076b0fc601a0b4d9
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Signed-off-by: Achraf <abz-odoo@users.noreply.github.com>
2021-04-13 15:52:08 +00:00
JF Aubert b71a62b515 [IMP] purchase: Purchase order portal view
Show the purchase orders which are in state "RFQ sent" on the portal
using two separate blocks (Requests for Quotation & Purchase Orders)
as done in Sales (Quotations & Sales Orders)

closes odoo/odoo#61035

Task: 2035476
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-04-07 13:49:46 +00:00
Adrien Widart 387e9a402a [FIX] purchase,purchase_product_matrix: ignore date planned
When adding a variant product, if the option "Variant Grid Entry" is
enabled, it will reset the delivery date of each purchase order line.

To reproduce the error:
(Use demo data)
1. In Settings, enable "Variant Grid Entry"
2. Create an RfQ
3. Add the field "Delivery Date" to purchase order line view
4. Add a basic product (e.g. "[FURN_6666] Acoustic Bloc Screens")
    - Keep its delivery date in mind
5. Add a variant product (e.g. "[E-COM12] Conference Chair (CONFIG)")

Error: The delivery date of the first purchase order line has changed
for no reason. Moreover, suppose that in step 4, the user defines a
specific date: the latter will still be changed after the variant
product is added.

When adding a product, the delivery date of the purchase order and its
lines are recomputed. However, an override of `onchange` ensures that
the new delivery date of the lines will be ignored if the `onchange`
concerns the field `order_line`. Here is the problem: when using the
Variant Grid Entry, the `onchange` concerns the field `grid`. As a
result, the new delivery dates are kept. This explains the creation of
`_must_delete_date_planned` in this fix.

However, when returing the result of an `onchange` linked to `grid`, the
result contains the existing lines (on client side) and the new ones
(from the Variant Grid Entry). If the field `date_planned` of the new
lines is deleted, the client will raise an error when it tries to render
these dates (it has no information about their value). Since existing
lines are of the form `(0, <client_id>, <values>)`, this fix only
deletes `date_planned` field for lines with <client_id> defined.

OPW-2454164

closes odoo/odoo#67972

X-original-commit: d2d495bca3e91862470702f1ef07aa27c33d8e2d
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-03-16 15:12:08 +00:00
Stefan Rijnhart 2861cf29b6 [FIX] Purchase double validation can be circumvented by RPC call
closes odoo/odoo#66606

X-original-commit: 99f891f0d1614b7a783fd55c0a9fdcb1ae6251da
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-02-22 13:01:59 +00:00
Jorge Pinna Puissant 6df75c0733 [FIX] purchase: convert standard price depending on the uom
- Install purchase and stock;
- Activate Units of Measure (uom);
- Create a new storable product;
- Choose a different uom for: 'Unit of Measure' (e.g., Dozens) and
    'Purchase Unit of Measure' (e.g., Units);
- Update the Cost (e.g. $ 300.00 per Dozens)
- Create a PO;
- Add the product.

Before this commit, the price on the PO will be 300 and the unit of
measure will be 'Units'.

Now, the price will be adapted to the 'Purchase Unit of Measure', in
this example it will be $25.0 per Unit.

opw-2439506

closes odoo/odoo#65119

X-original-commit: 27d251a17f3ccc597e2cd277b6d40a31dc9889b2
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2021-01-27 11:07:17 +00:00
Rémy Voet (ryv) bec794f776 [REF] stock,purchase(_*),mrp: clean related fields
Related fields are by default readonly and they should be when it
is possible. A editable related field will write on the related
model and will cause extra unwanted write of data. These unwanted write
can cause performance issues in some case (see odoo/odoo#63865).

Then remove the `readonly=False` of some related fields
(where it is useless):

- In 'mrp.workorder' (mrp): `working_state` and `production_date`
should be readonly.
- In 'purchase.order' (purchase): `product_id` should be readonly.
- In 'purchase.order.line' (purchase): `state` should be readonly.
- In 'product.supplierinfo' (purchase_requisition):
`purchase_requisition_id` should be readonly.
- In 'purchase.requisition' (purchase_requisition):
`product_id` should be readonly.
- In 'product.template' (stock):
`route_from_categ_ids` should be readonly.
- In 'stock.move.line' (stock):
`is_initial_demand_editable` should be readonly.
- In 'stock.move' (stock):
`product_tmpl_id` should be readonly.
- In 'stock.production.lot' (stock):
`product_uom_id` should be readonly.
- In 'stock.quant' (stock):
`product_tmpl_id` should be readonly.
- In 'stock.rule' (stock):
`route_sequence` should be readonly.
- In 'stock.change.product.qty' (stock):
`product_variant_count` should be readonly.
- In 'stock.return.picking.line' (stock):
`uom_id` should be readonly and also because it
is forced by `_prepare_stock_return_picking_line_vals_from_move`,
it should be related to the product uom not the one on the move.

task-2424248
2021-01-21 11:09:58 +00:00
Wolfgang Taferner 03f14189cb [FIX] account/purchase: onchange on purchase create bill does not work
closes odoo/odoo#64777

X-original-commit: 0f36bbd257ba5e8e03462f675d81fdbdece1893a
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-01-20 08:42:21 +00:00
Victor Feyens ca16c531a9 [FIX] purchase,purchase_stock: use correct company on PO creation
The picking_type and currency were taken from the current company, even if the
purchase order is created in another company.

Fixes #35026

closes odoo/odoo#64481

X-original-commit: 75936208c6e76a012027952f43b598e9d20180f3
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2021-01-13 13:43:33 +00:00
Jorge Pinna Puissant eb5f69af00 [FIX] purchase: avoid updating data_planned on section/note
Do not update the date_planned of section/note purchase lines when the
date is changed on the order.

Based on f3ebab6eb52e3dc8be1f030aecfff348a22f7e09

opw-2429853

closes odoo/odoo#64458

X-original-commit: c1d5a077f26d5cb5f42888f21dafd78e3432853f
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2021-01-13 09:58:12 +00:00
Lois Rilo 1c5489c8b5 [FIX] purchase: use a company consistent sequence numbering.
If a RFQ/PO is created with a specific company, its number must
be assigning using the sequence defined for that company with
disregard to current environment company. E.g. This issue can
easily arise when using aliases to create RFQ's.

closes odoo/odoo#63175

X-original-commit: 5de36feffd0347ff28c8fa35818e7bfc2535df4e
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-12-10 14:24:26 +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
Nicolas Martinelli 849a547699 [FIX] purchase: convert standard price currency
- Activate Multi-Currency, set a rate for a foreign currency
- Create a product with a cost of 10
- Create a PO
- Add the product

The price remains 10: it is not converted in the foreign currency.

Up to 13.0, a price of zero was set if no seller was found. This was
changed in 6b41dbf683 to set the standard price instead.
However, no currency conversion is performed.

opw-2394076

closes odoo/odoo#62831

X-original-commit: 315b7f822124fcd06c4c6ea7c8ecb8b7411338c5
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-12-03 13:53:56 +00:00