The following trick used to work, because `sudo()` was actually making
an environment for the superuser to operate upon:
request.env[...].sudo().method(...)
It no longer works in general, since `sudo()` now makes an environment
in superuser mode but with `uid=None`! It may still work by accident
for operations that never use `env.uid`, but is broken in general.
Using `auth='public'` fixes the problem by using the public user when no
user is available.
closesodoo/odoo#34297
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
In a list/kanban view when applying a default_order on the view, it does not
work with favourite filter
Before this commit,
1) The default_order was not applied to the view when favourite filter is
applied
2) when default_order applied, Click on an element of the list/kanban and
then go back to the list/kanban with the breadcrumbs, default_order has been
changed.
This is because the ```_getOrderedBy ``` returns [] when favourite filter is
applied and it does not have sort value, added check if favourite has orderedBy
and has length then and only then pass orderedBy else pass undefined
After this commit,
1) default_order will be applied to the view
2) default_order will not be changed when going back through breadcrumbs
task-1922576
closesodoo/odoo#34001
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit merges the following models
* account.invoice and account.move
* account.invoice.line and account.move.line
* account.voucher and account.move
* account.voucher.line and account.move.line
It was the opportunity for a big cleanup of the code, so it also restructures the whole account module, its different models/fields, the tests etc. for a better world and a better code readability.
==== Rationale ====
The rationale of this huge change is that we want journal entries / invoices to be easily edited, and changes reflected in the other model. It's a HUGE feature and very strategic for the fiduciary companies. For example, changing the account of a journal entry needs to be automatically reflected on the related invoice.
The same reasoning applies to sale/purchase vouchers.
==== Changes made in features =====
When creating an invoice, you are now creating a journal entry directly.
--> The object account.invoice no longer exists.
In the same fashion when creating an invoice line, you're now adding journal items directly in the journal entry representing the invoice. If this invoice line has some tax, it may create additional journal items as well.
--> The models account.invoice.line & account.invoice.tax no longer exist
Identically, when creating a sale/purchase receipt with its lines, you are now creating a journal entry directly and there's no more usability difference between encoding a receipt or an invoice.
--> The object account.voucher no longer exists.
--> The object account.voucher.line no longer exists.
--> The whole account_voucher module no longer exists.
Positive side-effects coming from these changes are
* draft invoices/bills/sale or purchase receipts now create a draft accounting entry. Validate these objects now simply post its journal entry. That means that draft invoices/bills/sale or purchase receipt can straightforwardly be included in reporting or budgets.
* opening a journal entry in form view will now always open the correct view: if it's a sale/purchase journal entry we will have a customer invoice/vendor bill view or a sale/purchase receipt view, whatever the menu we're coming from.
* code & business logic simplification. It is also condensed in a single place instead of being partially duplicated on invoices, vouchers and journal entries.
There should be no feature loss, except the one allowing to group multiple journal items together based on the same product during the invoice validation.
==== Changes made in models =====
* account.invoice: model removed. Instead, now use account.move with following mapping
field (account.invoice) field (account.move)
----------------------- --------------------
name invoice_payment_ref
number name
reference ref
comment narration
user_id invoice_user_id
amount_ total_company_signed amount_total_signed
residual amount_residual
state state + invoice_payment_state /!\ selection changed
date_invoice invoice_date
date_due invoice_date_due
sent invoice_sent
origin invoice_origin
payment_term_id invoice_payment_term_id
partner_bank_id invoice_partner_bank_id
incoterm_id invoice_incoterm_id
vendor_bill_id invoice_vendor_bill_id
source_email invoice_source_email
vendor_display_name invoice_vendor_display_name
invoice_icon invoice_vendor_icon
cash_rounding_id invoice_cash_rounding_id
sequence_number_next invoice_sequence_number_next
sequence_number_next_prefix invoice_sequence_number_next_prefix
'invoices' subset of account.move can be accessed by using the selection field 'type' or one of the many helpers like is_invoice()
* account.move: now has a valid state 'cancel' that has to be excluded from all business logic
* account.move: field 'amount' renamed into 'amount_total'
* account.move: field 'reverse_entry_id' renamed into 'reversed_entry_id'
* account.move.line: now has a field 'display_type' that has to be excluded from all business logic, in order to support invoice layouting
* account.invoice.line: model removed. Instead, now use account.move.line with following mapping
field (account.invoice.line) field (account.move.line)
---------------------------- -------------------------
invoice_id move_id
uom_id product_uom_id
invoice_line_tax_ids tax_ids
account_analytic_id analytic_account_id
'invoice lines' subset of all account.move.line from a journal entry can be accessed by using the boolean field 'exclude_from_invoice_tab'
* account.invoice.tax: model removed. Instead, now use account.move.line with following mapping
field (account.invoice.tax) field (account.move.line)
--------------------------- -------------------------
invoice_id move_id
account_analytic_id analytic_account_id
amount price_unit
base tax_base_amount
'tax lines' subset of all account.move.line from a journal entry can be accessed by using the relational field 'tax_line_id'
* account.invoice.confirm: model removed. Instead, now use the 'post()' function of account.move
* account.invoice.refund: model removed. Instead, now use account.move.reversal to reverse the entries with the same options as we had for invoices
* account.voucher: model removed. Instead, now use account.move of type in ['out_receipt', 'in_receipt]
* account.voucher.line: model removed. Instead, now use account.move.line
==== Changes made in functions ====
* on account.move, method _run_post_draft_to_post() renamed into _autopost_draft_entries()
* on account.move, method action_account_invoice_payment() renamed into action_invoice_register_payment()
* on account.move, method action_invoice_reconcile_to_check() renamed into action_open_matching_suspense_moves()
* on account.move, method _get_domain_edition_mode_available() renamed into _get_domain_matching_supsense_moves()
* on account.move, method _get_intrastat_country_id() renamed into _get_invoice_intrastat_country_id()
* on account.move.line, method _get_domain_for_edition_mode() renamed into _get_suspense_moves_domain()
* in account.bank.statement, contextual key 'edition_mode' renamed into 'suspense_moves_mode'
Was task 1917430
Previously the Forum errors were handled with a popover, now the
errors will be consistent with the crash_manager and display a toast
notification via the show_warning method.
Also the KarmaError were previously not displaying the karma needed to
perform the action. Now it will display the amount in the error message.
The CrashManager show_warning method will now take an options dictionary
as a second argument to override it's default behaviour.
Part of https://github.com/odoo/odoo/pull/32132
task-1894820
* = gamification, test_website, stock
- KarmaError is now handled as a 400 exception.
- test_website has been updated.
- NO_POSTMORTEM is now clean it was referencing duplicates as most the
exceptions inherit from except_orm.
- serialize_exception from http.py has been moved to ir_http
to take advantage of the odoo inheritance system. We can then
extend ir_http serialize_exception method to add the KarmaError
logic if and only if gamification is installed.
Places where serialize_exception was previously used are updated.
Part of https://github.com/odoo/odoo/pull/32132
task-1894820
* = account, iap, point_of_sale
Removing the CrashManager templates from base.xml and moving
it to a new file (crash_manager.xml) to allow lazy loading the required
xml only when a crash occurs (necessary for the frontend as no xml is
pre-loaded).
All rpc errors/warnings are now displayed using the same modal system as
the backend (crash_manager.js).
CrashManager will now return the WarningDialog and ErrorDialog
in addition to the CrashManager itself.
In some cases an instance of CrashManager was created just to
display a warning/error dialog.
In the backend all rpc errors but sessionExpired will be logged.
If the exception is a warning, NotFound (403) or except_orm, it will be
a warning log. The rest will be exception log.
In the frontend all rpc errors will be logged using console.debug
instead of console.warn and console.error. This way we can trigger
rpc errors in tests without failing them. If a real error happend
during a test it will fall back on the backend logger to fail the test.
Part of https://github.com/odoo/odoo/pull/32132
task-1894820
Moving the rpc_error binding into the crash manager is mandatory for it
to be used in the website.
Part of https://github.com/odoo/odoo/pull/32132
task-1894820
It's currently possible for binary downloads to be missing an
extension entirely. Generate an extension from the mimetype and use
that. Also ensure the existing extension (if any) matches the
mimetype.
Warning: this may require adding new mimetype/extensions pairs to the
local mimetype database similar to
f413d155df.
Also fix missing or incorrect filenames on records without a filename
field: in some Odoo versions the client would send a filename of
"null", resulting in a download of e.g. "null.pdf" instead of the
attachment or inferred name.
Task 2025716
closesodoo/odoo#34299
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Purpose
=======
This commit tests some behaviors with multi company
mode after changes brought by f847a46.
Specification
=============
Ensure the robustness of the switch company menu for
multiple cases like:
- Bar rendering
- Switch to another company in mono/multi environment
- Toggle another company in mono/multi environment
- Remove a company in mono/multi environment
The widget itself has been slighty modified to make
it more testable:
- Reading from session is now in the `willStart` function
instead of `init` to allow mocking the session (in tests,
`init` is executed before the mock is applied).
- In the event handlers, don't use `bbq` to retrieve
current allowed company ids. `bbq` is not easily nor
cleanly patched.
- When reading allowed company ids from session, cast
ids from string to integer. They are everywhere casted
except there.
and some linting
When we open any x2m record (in a FormViewDialog), there is a "Remove"
button to delete/unlink the opened record from parent.
This button is placed besides "Discard" button and it creates little
confusion in some cases. For example, in list view, there's already a
bin / 'x' icon depending on the field type using which people are used
to delete/unlink the record. And when they open a record, they might
accidentally click "Remove" button instead of "Discard".
To avoid this, now we won't show "Remove" button when we open record from
x2many list view. However, we have to keep this button in case x2many of
kanban as there's no other way to remove the record.
task-1886913
closesodoo/odoo#34333
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Purpose
=======
As the employee picture on a form view is often too small,
it should be possible to zoom on it like for products in eCommerce.
Specification
=============
Added new bool options on FieldBinaryImage: `zoom` and `background`.
`zoom` will call zoomOdoo.js and display a popup with the zoomed out
image.
`background` is used to either display the image as a div element with
a background-url (to be used e.g. in a kanban view) or as a standard
img element.
closesodoo/odoo#33839
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Before this fix, the many2one text in the list view was not wrapping.
After this fix, the text will wrap according to the available space
(managed automatically by the browser).
closesodoo/odoo#34345
Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
cache_hashes was introduced at 8a28cc22fd to reduce the number of reload
The cache is correctly reseted when the translations content changed but did
not contain all the translation-related parameters that are, however, stored
in the session_info
This commit fixes two bugs:
Language parameters invalidation:
1. Access the webclient in a specific language
2. Modify the language parameters (e.g. thousands separator)
3. Refresh the page
--> webclient is still using old language parameters (from cache)
No translation flag after installing a language:
1. Load a database in English in mono-language
2. Load a second language
3. Access a record with a translated field
--> translation button not present on translated field (multi_lang is still
false in cache value)
To fix it, this commit adds all the information that are returns by the
/web/webclient/translations call to make sure the hash represent the reality
closesodoo/odoo#34266
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
When e61639723d was forward-ported, there was an adapatation in 12.3
version with bbc8c9fc2 so the test pass (because of another issue where
if a line is moved after the draft line, the code tried to discard the
moved line and not the draft line).
The same adaptation is necessary in saas-12.4 but since the code changed
amply, the test was temporarily just skipped (in 83d0eaedc7).
With this changeset, the adaptation is forward-ported from saas-12.3 to
saas-12.4 and the test is re-enabled.
opw-1966589
closes#34277
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Before this commit, the No Change status wasn't properly set because
the `filehash` wasn't passed to `_binary_set_headers` and because
the status was not changed to 304 if it was already set to 200 earlier.
This commit fixes this issue and also prevents images to be processed
in `content_image` if the status is 304.
opw-2008426
closesodoo/odoo#34032
Signed-off-by: Christophe Simonis <chs@odoo.com>
The months name in momentjs used an arabic translation with the month
then some crap (or the month said a second time) after.
This does not seem expected, and has been solved in moment.js library 2
years ago:
https://github.com/moment/moment/pull/4271
This PR apply this change in moment.js localization included in Odoo.
opw-2006265
closes#34248
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
In case a many2one field (let us say 'foo') is used
simultaneously as a groupby and a measure in the pivot view,
the values returned by a read_group for that many2one are of
the form [id, label] and the aggregated values (always 1) are
missing in the read_group results (datapoints).
Thus typically, a datapoint is of the form
{'foo': [1, 'Bar'], '__count': 4, ...}
and does not contain information on the 'foo:count_distinct'
value (this is a read_group bug).
As a consequence, a special processing of the read_group
datapoints is done in the pivot model to handle that
situation and the value for 'foo:count_distinct' is infered
correctly to be 1.
In the pivot comparison mode, datapoints comming from the
period and the comparison period (data and comparisonData
sets) are identified if they have same values for the groupby
fields and the measure values become small objects containing
information on the the measure values for data and for
comparisonData and on the related variation.
Thus
{foo: [1, 'Bar'], __count: 4, ...}
from data and
{foo: [1, 'Bar'], __count: 3, ...}
from comparisonData should become a single datapoint
{
foo: [1, 'Bar'],
__count: {
data: 4,
comparisonData: 3,
variation: {
magnitude: +33 (%)
}
}
fooAggregate: {
data: 1,
comparisonData: 1,
variation: {
magnitude: 0 (%)
}
}
It turns out that the code responsible for merging the data
and comparison datapoints made a mistake by mixing the keys
'foo' and 'fooAggregate', with the consequence that the
variations were not correctly computed in the situation
described above.
This is fixed in this commit.
closesodoo/odoo#33118
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
A pie chart widget aims to instantiate a graph view in mode
'pie', with a measure and a single groupby specified via some
attributes. It turns out that if a pie chart is instantiated
in a context in which the keys 'graph_mode', 'graph_measure',
and 'graph_groupbys' are present, that keys prevail over the
pie chart specification. This can produce a line chart for
instance. This fix corrects that situation.
A test has been added in a corresponding commit in enterprise
(historically, the pie chart widgets are tested in dashboard
views).
closesodoo/odoo#34234
Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
- Create a calendar event
- In debug mode, remove the responsible
The 'Avatar Undefined' string is displayed at the botton of the
responsibles' list.
Do no fetch an image for a falsy value (= falsy id)
opw-2010007
closesodoo/odoo#34215
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
The search buttons visibility is saved in the local storage. Rev.
6448420 changed the API of the LocalStorage servive (by JSON
parsing the values), and didn't adapt the calls done for the
search buttons.
Closes#33833closesodoo/odoo#34206
Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
After a recent reorganization of the web client's components tree, the
class 'o_enable_linking' was added on the wrong element. This made the
css rule responsible of the highlighting of the clickable pivot cells
impossible to satisfy.
This commit fixes the issue by adding the class directly in the template
'PivotView'.
Additionally, this commit also makes visually clear when a field
selection menu-items is disabled (because it is already used) using
a 'not-allowed' cursor (which was removed in bs4). It is now again
possible to open a list view by clicking on a cell with zero value
(like in Odoo 11).
task-1916889
closesodoo/odoo#34165
Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
Before this commit, one could activate the two checkboxes "use by default", and "share for all users"
After this commit, only one out of the two can be checked
OPW 2010458
closesodoo/odoo#34167
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Configure your system to be in the Mexico timezone, configure your Odoo
profile accordingly. Go to calendar, show daily events, add an event at
the end of the day (like 10pm). The resulting event is not visible on
the daily view although it is on the weekly view. The same problem
occurs on the weekly view if the event was create late the last day.
The problem is the initial `search_read` has a domain to filter the
events using 00:00 UTC to 23:59 UTC boundaries. Those boundaries are not locale
aware, they should be shifted to the MX timezone.
opw-2009877
closesodoo/odoo#34247
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
It seems to be a better solution to keep starting tests without being in debug
mode to avoid having new fields and menus appearing.
This commit simply drop the debug mode in test mode and retrieve the test
assets by checking if test mode is enabled directly.
closesodoo/odoo#34012
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Since 72f7139f52, config.debug does not exist anymore, config.isDebug()
should be used.
Two commits merged at the same time were still using config.debug, 87a35d4263
and 88a26235caCloses#33961
Now we can display dialogs with or without header / footer / backdrop
and we can force the DOM to be put elsewhere than the body.
Part of https://github.com/odoo/odoo/pull/29353
task-1903256