Commit Graph
170 Commits
Author SHA1 Message Date
Hubert Van de Walle (huvw) 1076dbdd58 [FIX] purchase_requisition: add missing date_planned computation
Steps to reproduce
==================

- Create a blanket order
- Choose a vendor
- Add a product P
- Set a price
- Save and Confirm
- Click on the RFQs/Orders smart button
- Create a new RFQ
- Delete the line
- Add a new line with the same product P
- Save

-> A validation error appears because the date_planned is not set

Cause of the issue
==================

`_compute_price_unit_and_date_planned_and_name` is overriden and passes
an empty recordset to the super method.

Solution
========

We can compute the `date_planned` using the selected seller

opw-3416573

closes odoo/odoo#132428

X-original-commit: d7db1d799fe042ef248968c6dee53eaf6e0ed3db
Signed-off-by: Tiffany Chang (tic) <tic@odoo.com>
2023-08-21 12:39:47 +02:00
Gorash 75a105f46a [REF] base/all: Update modifier syntax: remove 'states' from fields
These changes are made as a result of simplifying attrs and 'states' in
views. However, they should have remained in a separate commit. When
applying the script making the xml changes (used later for the migration
script), the script checked the definition of the python fields in order
to convert the information into a python expression. Therefore, this
commit is not applied when the script is applied to xml changes.

During this attribute deletion pre-existing errors were found. Part of
the code was using the boolean values of 'states' and another part of
the code was not. The behavior could therefore be different (in cases
where readonly on the field had the same value as the ballan in
'states').

Following the deletion of 'states' and without the application of the
view migration, the js tests (tower) were no longer functional. Tests
using the Form view suffered the same effect. There are few tests that
had to be adapted, including two tests in business accounting (updated
by the accounting team). A test for column_invisible did not work. Test
checking if the test system triggers an error if we try to write on an
invisible field. It turns out that Form was testing on the value of
invisible but not taking into account if the column was invisible. The
test system fix is applied separately because there were a lot of tests
that were incorrect.

Part-of: odoo/odoo#104741
2023-08-18 09:49:11 +02:00
stcc-odoo 5618236ce2 [FIX] purchase_requisition: fix multicurrency alternative
Steps to reproduce:

- Activate 2 currencies (assume EUR and USD, conversion rate: 1 EUR = 0.9 USD)
- Create new product P
	- Purchase tab, add two vendors
	- V_USD, currency = USD, price = 100
	- V_EUR, currency = EUR, price = 101
- Create PO, vendor = V_USD, Currency = USD
- Add P, Unit price should be 100
- Alternative tab > Create alternative > Vendor = V_EUR
- Compare product lines

Issue:

The line with price = 100 USD is highlighted as being the cheapest option, but if we apply conversion rules,
101 EUR = 90.9 USD < 100 USD.

Solution:

Convert prices in company currency before comparing.

opw-3378253

closes odoo/odoo#129984

X-original-commit: 8e53914362eaf29675051e157dbcfdbfbdec88da
Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-07-28 16:29:11 +02:00
Touati Djamel (otd) 934d9a5caa [FIX] purchase_requisition: create a PO alternative with note & section
Steps to reproduce the bug:
- Create a PO:
    - Add a product
    - Add a note or section
- Go To Alternatives:
    - Click on “Create Alternative”
         - Add another vendor
         - Try to validate

Problem:
An error is triggered: “The operation cannot be completed: Description
(name) is mandatory”

The “display_type” and “name” fields must be copied in the vals to
create a `purchase.order.line`

opw-3164863

closes odoo/odoo#115070

X-original-commit: 66f806399d173f53b61db80b81d06a93421c75a3
Signed-off-by: Tiffany Chang <tic@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2023-03-13 15:28:01 +01:00
svs-odoo 4dd3104b96 [IMP] product_expiry,purchase_requisition,stock*: visual changes
- The `picking_type_id` field in the pickings form view is not openable;

- Display the `description` field (optional) in the SVL list view;

- Add the `expiration_date` field (optional) in the quant list views;

- Add a description text for the landed cost;

- Renames field `requisition_id`: "Purchase Agreement" > "Blanket Order"

- In Inventory Adjustment, hides the "Apply All" button is at least one
  record is selected;

- In `product_expiry`, renames two views to stick to the XML's coding
  guidelines: https://www.odoo.com/documentation/16.0/contributing/development/coding_guidelines.html#xml-ids-and-naming

- For the replenishment:
  - Places the field `product_id` as the first option when the user
    writes something in the searchbar;
  - Renames `route_id`: "Preferred Route" > "Route";
  - Renames the button "Automate Orders" into "Automate";
  - Set the `route_id` field as "optional=hide" until `mrp_purchase` is
    installed (in this case, it will be set as "optional=show") because
    in this case, there is at least two routes (Buy and Manufacturing).

task-3076044

Part-of: odoo/odoo#109511
2023-02-13 15:15:06 +01:00
niyasraphy 802d50219f [IMP] purchase_requisition: blanket order reference
currently on confirming a blanket order will generate a reference for the record using the sequence and once the record is moved to cancel state and clicking the reset to draft button is clearing the already assigned reference number.

and on clicking confirm again will generate a new reference number for the same record.

this pr will stop clearing the sequence number on reset to draft button.

closes odoo/odoo#108574

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-02-10 09:11:48 +01:00
niyasraphy 2f069b9ce8 [FIX] purchase_requisition: access right error on confirm/cancel bo
before this commit, on closing/confirming a blanket order by a purchase user throws access right on product_supplierinfo model.

after this commit, access right error will not be shown on confirming and closing the blanket order.

closes odoo/odoo#111896

X-original-commit: 9d86621029a478b8e1cbae4f228fe454a184fba3
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-02-03 17:41:18 +01:00
niyasraphy 9a3a41202a [FIX] purchase_requisition, stock: improve usererror to show allowed stages
in purchase_requisition and stock module, when deleting a requisition and move, the raised warning says,the deletion can be done only in draft moves, where us the deletion is allowed for the cancelled records also.

improving the user error message to include the cancelled records in the message.

closes odoo/odoo#110340

X-original-commit: b71d298dabb4436182c0eb516d5a7b7e76fca437
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-01-19 12:30:59 +01:00
Thibault Delavallée 4775bd93a2 [REF] mail: cleanup post with {view, template} wrappers
RATIONALE

Purpose of this commit is to cleanup main post helpers and have a more easy
and understandable way of calling them.

SUMMARY

We now have two main API methods, based on business flow: either posting
on documents, either sending a mass mailing. Indeed those two flows are
different

  * post: create message, then launch notification process by taking into
    account subtype, followers, ...
  * mail: create mails in batch with recipients being based on template or
    given partners. No notifications is involved, only maybe traces if a
    mass mailing is linked

Delegate QWeb rendering to the render mixin (i.e. _render_template_qweb_view)
in order to have a single point to forge evaluation context and re-use
existing rendering code.

SPECIFICATIONS

Main API helpers are now

  * ``message_post_with_source``: (batch) post on records, using an ir.ui.view
    (given a record or its xml id) or a mail.template record (given a record or
    its xml id). When using a template, a composer is called to post on each
    record (as batch post is not yet supported). When using a view, a direct
    call to message_post using the rendered bodies is done, one record at a
    time.
  * ``message_mail_with_source``: send a mass mailing on records, acting like
    invoking the mail composer in mass mode. Same arguments are valid, either
    a reference to a view, either a reference to a mail template.

Other helpers are

  * ``_message_log_with_view``: (batch) log on records, using an ir.ui.view
    to render the body using QWeb (no notification process);
  * ``_message_log(_batch)``: (batch) log on records (no notification process);
  * ``message_notify``: notify partners on records (creating notifications
    specifically for some people while message itself is not displayed in
    chatter);

Code migration

  * ``message_post_with_template`` in "mass mode": use ``message_mail_with_source``
    and set the template record as source;
  * ``message_post_with_template`` in "comment" mode: use ``message_post_with_source``
    and set the template record as source;
  * ``message_post_with_view``: its main usage was to post on a document, in which
    case it generally can be replaced by ``message_mail_with_source`` using
    the view reference as source;

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:34 +01:00
Thibault Delavallée 418761e344 [LINT] mail, various: use explicit subtype in message_post_{with_...}
RATIONALE

Purpose of this commit is to be explicit in subtype chosen when invoking the
message composer / calling message_post. As default value may not always be
clear, better be explicit in case the composer default value changes.

SPECIFICATIONS

Add explicit references to subtype when it is not obvious what will be the
final subtype, notably when using helpers (post_with_view or template which
uses the composer that is not crystal clear in its subtype management).

In this commit we also add support of XMLID-based subtype when invoking the
composer. A ``default_subtype_xmlid`` context key is transformed into a
``default_subtype_id``, to be used notably in JS where we cannot easily
use a ``ref``-like statement. Post API now also supports 'subytpe_xmlid'
argument allowing to give the xml id and ease calling the methods.

Use ``_xmlid_to_res_id`` to get directly the ID of subtypes in order to
avoid useless queries from ``ref`` that does an exists.

Also remove useless values given to post API, notably author_id that is by
default the current users' partner.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:33 +01:00
niyasraphy 9b603054ed [FIX] purchase_requisition: fix singleton error
Activate Product variants and create a new products with attributes Legs, Size and color.

Now enable Variant Grid Entry and Purchase Agreements from purchase settings and now create a Blanket Order from Purchase -> Orders -> Blanket Orders with any products from above created variants.

Confirm the created blanked order and click on New Quotation, now a new RFQ will be created, and click on add an item button and select the product we have created before, now Choose Product Variants matrix will be opened. Enter some random quantities in multiple lines and click on confirm button.

Exception will be raised

closes odoo/odoo#106572

X-original-commit: ca94ace181675b6e150c0f7486de9495198dc8e8
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-11-25 18:55:40 +01:00
clesgow 258ac595a0 [FIX] purchase_requisition: Compare product lines
Steps to reproduce:
- Create a product with both MTO and Buy routes.
- Create a Sale Order containing this product.
- On the created PO, go to Alternatives -> Create Alternative and select
another vendor.
- Go back to the original Sale Order
- Click on the linked Purchase Order
- Go to Alternatives -> Compare Product Lines

When doing this, the `active_id` in the context is the id of the Sale
Order, which raises an issue in the renderer for this list as it's using
the active_id as if it was the Purchase Order.

closes odoo/odoo#106481

X-original-commit: 1b904ece76f55f8e416d868256720f41cba8ceb1
Signed-off-by: Tiffany Chang <tic@odoo.com>
Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com>
2022-11-25 09:53:13 +01:00
niyasraphy 850bb0a9d9 [FIX] purchase_requisition: wrong seller in context to get supplier info
the context passed to the method _get_product_purchase_description for the seller_id is wrong. system is expecting to get product.supplierinfo record set in this context key and from this function res.partner record set is passed, which results in the below error:

Record does not exist or has been deleted.
(Record: product.supplierinfo(70,), User: 2)

closes odoo/odoo#105998

X-original-commit: 6e7f778e1d0dbe4795fa9446bfd3542ecec9815c
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-11-18 12:58:16 +01:00
Tiffany Chang (tic) 4e32d1fe37 [FIX] purchase_requsition: ensure product_uom_id exists in bo lines
Previous commit 0501bbd62e made it so
the `product_uom_id` for the `line_ids` of a purchase.requsition (i.e. a
blanket order) were no longer being saved when the UoM setting is not
active. This would cause an error to occur when the "New Quotation"
button is pushed because the missing uom is expected by purchase
_onchange_requisition_id.

Steps to reproduce:
- Have UoM setting NOT active
- Create a blanket order for any product/vendor
- Confirm the blanket order
- Click on "New Quotation"

Expected Behavior:
New RFQ created

Actual Behavior:
Stacktrace

We also properly restrict the product_uom_id in the form view of the
line_ids to when the uom setting is active.

closes odoo/odoo#104900

X-original-commit: e90200a7b927ecccb8d4d6f31e3ddecba24d0b6d
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-11-17 11:58:50 +01:00
niyasraphy 7ba966d3e2 [FIX] purchase_requisition: typo for quantites
closes odoo/odoo#105442

X-original-commit: 9dd93b697a6ff50314b2fb2e5894b7125b8b207a
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-11-09 15:04:06 +01:00
niyasraphy 91a52f71c1 [FIX] purchase_requisition: wrong field name in function
closes odoo/odoo#105156

X-original-commit: f6d0482b031d03af227f9765d5e5ee981342a913
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-11-07 15:57:33 +01:00
Tiffany Chang (tic) c9ea3fcac6 [IMP] purchase_requsition: convert custom js to OWL
For original specs, see [1].

Some performance changes: the best price/date/unit price fields are now
loaded by JS instead of passed via action context (allows for easier/
consistent reuse of view + now we can refresh without undoing any state
changes due to buttons being pushed).

[1] https://github.com/odoo/odoo/commit/f533e40f0e3f1cd34f1047b70dfdf95837d84501

closes odoo/odoo#101502

X-original-commit: 41ae508c2e6fc3c40b29b1bfc4b5dd7c4440a719
Signed-off-by: Antony Lesuisse <al@odoo.com>
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-09-29 12:16:58 +02:00
gawa-odooandHabib 7e3403068f [REF] *: Analytic Apocalypse
The goal of this commit is to get rid of the analytic tags as they were confusing, serving tag purposes as well as distribution on analytic accounts.

Everywhere analytic tags were used as a distribution have been replaced with a new widget that will dispatch distribution on analytic accounts. If there was an analytic account field next to the tags, it has been included in the distribution.

Analytic tags that were used simply as information tags have been removed.

To fill the new widget, there are now 2 kind of rules that will help fill and prefill it.
The first are applicability: previous groups have been removed, and have by replaced by plans. Each account is required to have a plan. These plans define when they are available in the widget: a default applicability per plan and applicability lines that can specify rules following the context of the widget.

The second one are distribution models, that will replace previous default rules but follow the same principles. The accounts (and so the plans) that will be given by the distribution model can override the applicability rules from before.

closes odoo/odoo#98914

Related: odoo/upgrade#3885
Related: odoo/enterprise#30743
Signed-off-by: William André (wan) <wan@odoo.com>
Co-authored-by: Habib (ayh) <ayh@odoo.com>
2022-09-20 12:36:01 +02:00
Thibault Delavallée 3cdc217736 [FIX] purchase_requisition: fix usage of message_post_with_view in batch
In order to post on a document, ``message_post_with_view`` should be called
on a singleton recordset. Otherwise it is done as a mass mailing which is
not really what is expected here.

Task-2710804 (Mail: Clean MailThread API)

Part-of: odoo/odoo#100137
2022-09-15 01:23:27 +02:00
Tiffany Chang (tic) f533e40f0e [IMP] purchase_requisition{_stock}: add new alternative POs option
Previously the "call to tender" flow involved creating a
`purchase.requisition` record, creating each RFQ via that record, and
then manually going through each RFQ to compare the prices/dates/etc.
By linking the "call to tender" POs within the POs, we remove an
unnecessary `purchase.requestion` record and makes it easier to track
which RFQs are related to each other as an Alternative RFQ.

On top of this, we add some comparision features to make it easier to
determine the best RFQ, specificially the ability to compare PO lines in
the same view with some visual aids (best price/date colored green +
buttons to check these lines to make them easier to view). We also add
an extra feature to set the qty of selected/non-chosen PO lines to 0 to
aid in the RFQ selection process (only applies to non-confirmed/done/
cancelled POs).

Some other features included with this:
- option to cancel alternative POs when confirming one, which purposely
  does not cancel ones that have already been confirmed/completed.
- new wizard for creating alternative POs so user can select whether or
  not they want to copy the products/qtys from the original PO.

Important Notes:
- JS Customizations:
  - custom many2many widget added so user:
    - can click between alternative POs in same window + keep breadcrumb.
      This is because all alt POs are interconnected and long breadcrumb
      chain is possible (+ we want to avoid windows within windows.) It
      is expected that user will be aware that unsaved changes will
      auto-save when alt PO is clicked on.
    - cannot unlink a PO from itself (this is automagically done during
      the write) since this will remove all of its linked POs and might
      confuse users.
  - custom view js for Comparing Order Lines to help highlight best
    options, including ensuring that the best options are still
    highlighted after clicking on Choose/Clear buttons (since the best
    option can change afterwards, we recalc + update via RPC)
- General implementation warnings:
  - Anytime any button/alternative PO is clicked on within a PO, the
    form will auto-save. This is due to how the current action service
    handles changing views.
  - POs created via "Create Alternative" button purposely:
     - require a vendor to ensure correct lead times/prices
     - show all vendor/product warnings in wizard because we cannot
       reproduce the pop-up warning that would occur in the PO when
       they are selected. We also purposely block the PO creation when a
       blocking warning is set since we cannot remove the values
       (especially in the case of a blocking vendor message) from a
       newly created PO.
  - Technical purchase.order.group model created to help with difficult
    management of complicated behaviors:
     - unlink from self if a PO is no longer linked to any other POs
     - linkages must be symmetric (i.e. linkage PO1 => PO2 must
       reflect PO2 => PO1 in their form views)
     - don't lose existing linkages (i.e. PO1 => PO2 and PO2 => PO3
       should auto-link PO1 => PO3)
    These last two behaviors are difficult to do without grouping due to
    possibility of remove and adding linkages at the same time. To avoid
    complex code to ensure these complexities hold when when creating a
    new PO, linkaging to alternatives is not allowed when PO is not yet
    saved as a record.

Task: 2695116
Upgrade PR: odoo/upgrade#3586

closes odoo/odoo#87656

Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2022-06-20 12:15:59 +02:00
Tiffany Chang (tic) 863c5090f0 [REF] purchase{_various}: make onchange_quantity computed
Instead of having to repeatedly manually call `onchange_quantity` at
different points in the code, it is better to have it be computed
instead.
- Logic is left unchanged,
- onchange calls from other methods are removed, and
- tests are adjusted to properly handle compute. I.e. remove
'date_planned': datetime.today().strftime(DEFAULT_SERVER_DATETIME_FORMAT)
  from when PO lines are created since this sometimes resulted in
  inconsistent date_planned values for PO line and the PO date_order
  (by 1 sec), which could lead to inconsistently created 'date_deadline'
  values for stock_moves' created by PO line qty changes. Issue
  previously didn't exist because onchange was not always called.

Part of Task: 2695116 (to avoid adding more onchange calls for new
feature)

Part-of: odoo/odoo#87656
2022-06-20 12:15:59 +02:00
Tiffany Chang (tic) 00689e7fc6 [REM] purchase_requisition{_stock}: rem old call to tender pt2
This commit removes the call for tender feature via a
purchase.requisition. This feature is to be replaced with the ability to
directly compare prices/options of POs/RFQs within a PO to remove extra
steps to compare them. The linkage between POs previously provided by a
purchase.requistion is replaced by the POs being directly linked to each
other. Feature to auto-create call to tenders via a product option is
removed and the user is expected to know/be responsible for when they
should do a call to tender themselves.

All references to old Call to Tenders replaced with Blanket Order, and
we remove/rename the menu items since Blanket Order is now the only
purchase.requisition.type option (we expect minimal customizated types).
Follow-on refactoring to switch purchase.requisition to
purchase.blanket.order to come later. Follow-on refactoring to switch
purchase.requisition to purchase.blanket.order to come later.

Part of Task: 2695116
Upgrade PR: odoo/upgrade#3586

Part-of: odoo/odoo#87656
2022-06-20 12:15:58 +02: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 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
roen-odoo 76b556fd3c [FIX] purchase_requisition : PO Agreements wrong qty ordered
Current behavior:
If you have 2 time the same product in the agreement and you confirm an order with just one line of this item
the 2 lines in the agreement will have the quantity.

Expected behavior:
Only the ordered item should have the quantity applied. In this case the products are compared with the price and
product ID. If you modify the price in the PO the first line of the agreement will have the quantity by default.

Steps to reproduce:
1. Create a new Purchase Agreement
-Add two lines with the same product
- First line has a scheduled date and price that are different from the second line
2. Generate RFQ and confirm PO with only the first product line and a set quantity
3. Once the PO has been confirmed, going back to the Purchase Agreement, the ordered quantities on both lines will be the same, although the PO was generated for only the first line.

opw-2627898

closes odoo/odoo#79322

X-original-commit: c09a16fb2483e8cec4c9c9e6a936ae2bcc490646
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Engels Robin (roen) <roen@odoo.com>
2021-11-03 14:12:46 +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
Julien Castiaux b8b89bf47d [FIX] core: prevent redundant default on related
Setting a default value on a readonly related field without an inverse
method is nonsense.  We log some warning when it happens.

We also fixed other cases where a related field has a default value
that overrides the target field's value.

closes odoo/odoo#67762

Related: odoo/enterprise#17313
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2021-09-07 15:49:48 +00: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
Goffin Simon 2327cc45fc [FIX] purchase_requisition: Wrong translation
Steps to reproduce the bug:

1. Activate the 2 language “’English’ , ‘Spanish (AR) / Español (AR)’ ”
2. User -> select the language ‘Spanish (AR) / Español (AR)’
3. Create a new product (Test Product).
4. Create a another product using “Duplicate” function.
5. Rename new product name(Test Product -1)
6. Translate the name ( “Spanish (AR) / Español (AR) : 111 Spanish product “ , “English: English Product” )
7. create a purchase agreement -> select product “111 Spanish product ” -> Save -> confirm -> new quotation.
8. Purchase Quotation -> Order line

Bug:

Description shows “Test Item (copia)”

opw:2582778

closes odoo/odoo#72997

X-original-commit: 947484cd9a082003bfd5b3c2e64d6033b863aa84
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2021-06-30 12:11:43 +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
newtratip 519535febf [IMP] purchase_requisition: Add archived in purchase agreement types
closes odoo/odoo#71254

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-05-26 09:57:28 +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
Goffin Simon e8fea60bb8 [FIX] purchase_requisition: Purchase Order Approval
Steps to reproduce the bug:

- Create a user with only access rights, Inventory = Administrator, Purchase = user
- Enable feature Purchase order approval in Purchase > Settings
- Agreement Type = Exclusive, lines of Agreement, Quantity of Agreement
- Login as a new created user and navigate to a menu Purchase > Purchase agreement and
create a new Purchase agreement, confirm it
- From the button create two PO (having a total > 5000)
- Cancel one of the PO first and try to approve another one

Bug:

A UserError was riased: You have to cancel or validate every RFQ before closing the purchase requisition.

opw:2368999

closes odoo/odoo#64431

X-original-commit: dfee34b0b9c83beca9aca0b21e7f130ae86c0ee6
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2021-01-12 15:42:15 +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
Martin Trigaux 2683184aa6 [FIX] *: fix all the typos
And other reported English mistakes in source string
Courtesy of Transifex translators

And remove leftover from gengo

closes odoo/odoo#59022

X-original-commit: 26efc84c5cac47a2cc83d7b084f8b71528fec6c7
Related: odoo/enterprise#13781
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-10-05 09:36:34 +00:00
Victor Feyens c482fdbf05 [IMP] various: improve code style and performance by improve `all()` usage
PURPOSE

Clean code. Be more performance oriented.

SPECIFICATIONS

Improvements applied in this commit

  * not all() --> any(not) for earlier returns;
  * all([generator]) --> all(generator) to avoid unnecessary list casting.
    This code construct is better managed by all;

This commit will probably not have a big performance effect on standard
production databases. However each performance and cleaning improvement
is welcomed.

LINKS

Task ID-2328619

closes odoo/odoo#56810

X-original-commit: 1cc6bb1231401ea7f501d2f5b5e9641ec8734850
Related: odoo/enterprise#12802
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-08-31 13:59:27 +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
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
Denis Ledoux 66409d470e [FIX] purchase_requisition: state_blanket_order on multiple records
Reading `state_blanket_order` on multiple records was failing.

e.g.
```python
env['purchase.requisition'].create({})
env['purchase.requisition'].create({})
env['purchase.requisition'].search([]).mapped('state_blanket_order')
```
raised
```python
ValueError: Expected singleton: purchase.requisition(5, 1, 4)
```

closes odoo/odoo#48642

X-original-commit: 031c3f3b0b387cfaf4257cf769c0523097723fc5
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2020-03-30 23:44:07 +00:00
Laurent Stukkens (LTU) 38294dbc99 [IMP] purchase, purchase_requisition: improve UX
Several improvements in order to improve user interface are done here.

[IMP] purchase: Prevent create PO&RFQ in calendar
   It was possible to create PO's and RFQ's from the calendar view.
   The Product Owner wanted to prevent the users from doing so.

[IMP] purchase: Add tooltip to Receipt Date

[FIX] purchase: Align report & stat button data on product form
   The use of Last 365 days time_range in the purchase analysis was automatically
   excluding today's purchases wich was confusing users as the stat button info
   was taking those into account.

   Different behaviours were implemented for product template and product product
   in the filters that were used which makes no sense.

   Use of context_today() instead of datetime.now() in order to take the user's
   timezone into account.

[IMP] purchase: Use relevant dates for RFQ's and PO's in calendar view
   The date used in order to display RFQs and POs in the calendar was date_planned
   which is not mandatory and so not always filled. It has been decided to use the
   order_date for the RFQ's and date_approve for PO's.

[IMP] purchase_requisition: Making Agreement selection type more explicit

[IMP] purchase: Show UOM menu only if installed

[IMP] purchase: Add product variant in settings

[IMP] purchase: Remove Favorites predefined filters

[IMP] purchase: Rephrase PO action helper

[IMP] purchase: Allow open/edit Agreement Type

[IMP] purchase: Rephrase RFQ action helper

[IMP] purchase: Remove PO's and RFQ's name from fields in calendar
   The Product Owner originally wanted to have a link on the PO name field
   that was shown in the calendat popover. As the Edit button already allows
   to edit the PO's or RFQ's from the popover it was decided to simply remove
   the field (as it was already displayed at the top of the popover)

[IMP] purchase: Open the right view when click on Reporting top menu

Task ID #2196688
Closes #47810

Related: odoo/enterprise#9294
Related: odoo/upgrade#961
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-03-31 08:08:22 +00:00
William Henrotin 31db39a052 [FIX] purchase_requisition: correct search domain
bug introduced by ef16266ad6

Task : 2210230

closes odoo/odoo#47400

Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2020-03-11 13:40:53 +00:00
Arnold Moyaux abef168389 [IMP] purchase_requistion, purchase_requisition_stock: custom variant
Allow to use custom product decscription on requisition line.

closes odoo/odoo#34174

Task: 1970476
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2020-03-05 14:31:13 +00:00
Arnold Moyaux 7eb22cef2f [IMP] purchase_requisition: remove useless inherit
_prepapre_tender_values in only call from purchase_requisition_stock.
It's not needed to have 2 functions, everything should be in
purchase_requisition_stock.
2020-03-05 14:31:13 +00:00
Victor Feyens ef16266ad6 [FIX] purchase_*: ensure properties are read with the correct company. 2020-02-27 12:19:24 +00:00
jerome hanke (jhk) 79e6d9f93f [FIX] purchase_requisition: currency updated on blanket order vendor change
Steps to reproduce:
- install contacts and purchase
- go to purchase > configuration > settings > activate "purchase agreements"
- go to general settings and activate multi-currency
- go to contacts > select a contact > edit > sale & purchase > change the currency
- go to purchase > purchase agreements > create
- change the agreement to a blanket order > add your modified contact as the vendor

Previous behavior:
the currency is not updated

Current behavior:
the currency is updated on vendor change

opw-2177431

closes odoo/odoo#43877

X-original-commit: 764135630949eb01cb2b3a4a19d6ec5b1bd39400
Signed-off-by: mightyjol <jhk-odoo@users.noreply.github.com>
2020-01-23 19:10:57 +00:00
Arnold Moyaux bce112678a [IMP] product, purchase_requisition, purchase_stock: _prepare_seller args to kwargs 2020-01-09 16:09:12 +00:00
Victor Feyens 600d0707ae [IMP] *: use get_fiscal_position and not property_account_position_id.
And adapt to get_fiscal_position changes

closes odoo/odoo#40336

Related: odoo/enterprise#6840
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2019-11-20 14:42:07 +00:00
Victor Feyens 1197821583 [IMP] account: fiscal position little cleanup
* No api model for methods using self
* Use new orm abilities to cleanup map_tax method
2019-11-20 11:40:28 +00:00
Victor Feyens 57b999d40a [FIX] sale,account,purchase_requisition: multi-company
Use correct company to get fiscal positions and properties

Ensure company used to fetch fiscal positions is always the correct one
when coming from a company restricted model (company_id required, or
related.required).

NB: if the company_id isn't defined, with_company doesn't change the
environment.

purchase: get_fiscal_position doesn't consider company_id ctxt key

others: properties were accessed with potentially the wrong company.
2019-11-18 12:25:05 +00:00
Arnold Moyaux d8355a0087 [FIX] purchase_requistion: call for tender zero lines
Usecase to reproduce:
- Create a purchase requistion with type Call For Tender
- Update a line and set the price to zero.

UserError 'You cannot confirm the blanket order without price.' raised.
It happens because the write don't process the same check than create
and don't check if the purchase_requistion is a blanket order or a call
for tender. It also doens't check the current state of the
purchase_requisition.

closes odoo/odoo#39980

Task: 2120211
X-original-commit: 7d69f01477a2d5dd93974737978d7af11cfc8b6d
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2019-11-07 16:18:13 +00:00