Syntax-error: Non keyword-arg after keyword arg - OpenErp - python

I got this error
Client Traceback (most recent call last):
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\openerp\addons\web\http.py", line 203, in dispatch
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\openerp\addons\web\controllers\main.py", line 1410, in load
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\openerp\addons\web\session.py", line 43, in proxy
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\openerp\addons\web\session.py", line 31, in proxy_method
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\openerp\addons\web\session.py", line 104, in send
Server Traceback (most recent call last):
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\openerp\addons\web\session.py", line 90, in send
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\.\openerp\netsvc.py", line 293, in dispatch_rpc
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\.\openerp\service\web_services.py", line 622, in dispatch
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\.\openerp\service\security.py", line 40, in check
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\.\openerp\pooler.py", line 49, in get_pool
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\.\openerp\pooler.py", line 33, in get_db_and_pool
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\.\openerp\modules\registry.py", line 192, in get
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\.\openerp\modules\registry.py", line 218, in new
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\.\openerp\modules\loading.py", line 344, in load_modules
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\.\openerp\modules\loading.py", line 259, in load_marked_modules
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\.\openerp\modules\loading.py", line 162, in load_module_graph
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\.\openerp\modules\module.py", line 405, in load_openerp_module
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\.\openerp\modules\module.py", line 133, in load_module
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\openerp\addons\certificados\__init__.py", line 1, in <module>
File "C:\Program Files\OpenERP 7.0-20130321-002353\Server\server\openerp\addons\certificados\certificados.py", line 37
'Valor_En_Divisas' : fields.function(multi_a_b, type='integer', 'Valor En Divisas'),
SyntaxError: non-keyword arg after keyword arg
And this is the code in my module.py
_columns = {
'Codigo_Arancelario' : fields.integer('Codigo Arancelario'),
'product_id' : fields.many2one('product.product', 'Material'),
'Descripcion_Arancelaria' : fields.char('Descripcion Arancelaria', size=42, required = True, translate = True),
'Especificaciones_Tecnicas' : fields.char('Especificaciones Tecnicas', size=60, required = True, translate = True),
'Cantidad' : fields.float('Cantidad'), 'Unidad_de_Medida': fields.many2one('product.uom', 'Unidad de Medida'),
'Precio_Unitario_Declarado' : fields.float('Precio Unitario Declarado'), 'Moneda' : fields.many2one('res.currency', 'Moneda'),
'Valor_En_Divisas' : fields.function(multi_a_b, type='integer', 'Valor En Divisas'),
'requisicion_id' : fields.many2one('certificados.certificados', 'Certificados de No Produccion', ondelete='cascade'),
'Cantidad_Consumida' : fields.float('Cantidad Consumida'), 'Cantidad_Disponible' : fields.float('Cantidad Disponible'),
}
Being "Valor_En_Divisas" the error syntax, but i don't know what is exactly giving me this error?
Any help would be greatly appreciated.

You have a non-keyword argument:
fields.function(multi_a_b, type='integer', 'Valor En Divisas'),
^^^^^^^^^^^^^^^^^^
After a keyword argument:
fields.function(multi_a_b, type='integer', 'Valor En Divisas'),
^^^^^^^^^^^^^^
To fix it, make that last one a keyword argument:
fields.function(multi_a_b, type='integer', string='Valor En Divisas'),

Related

localstack status services command is giving a JSON error

getting a frustrating issue when running 'status services' against a running localstack, which appears to have started without error.
Most of the awslocal commands I attempt to run against localstack seem to work ok, so I am confused as to why 'localstack status services' fails
Error is below:
$ localstack status services
Traceback (most recent call last):
File "/usr/local/Cellar/localstack/1.3.1/libexec/lib/python3.11/site-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python#3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python#3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python#3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/localstack", line 23, in <module>
main()
File "/usr/local/bin/localstack", line 19, in main
main.main()
File "/usr/local/Cellar/localstack/1.3.1/libexec/lib/python3.11/site-packages/localstack/cli/main.py", line 11, in main
cli()
File "/usr/local/Cellar/localstack/1.3.1/libexec/lib/python3.11/site-packages/localstack/cli/plugin.py", line 15, in __call__
self.group(*args, **kwargs)
File "/usr/local/Cellar/localstack/1.3.1/libexec/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/localstack/1.3.1/libexec/lib/python3.11/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/localstack/1.3.1/libexec/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/localstack/1.3.1/libexec/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/localstack/1.3.1/libexec/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/localstack/1.3.1/libexec/lib/python3.11/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/localstack/1.3.1/libexec/lib/python3.11/site-packages/localstack/cli/localstack.py", line 94, in cmd_status_services
doc = health.json()
^^^^^^^^^^^^^
File "/usr/local/Cellar/localstack/1.3.1/libexec/lib/python3.11/site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Hoping somebody has seen this before!
Edited this to reply to #thrau as the comment is too long...
$ curl localhost:4566/health
{"services": {"apigateway": "running", "cloudformation": "running", "cloudwatch": "running", "dynamodb": "running", "dynamodbstreams": "running", "ec2": "running", "es": "running", "firehose": "running", "iam": "running", "sts": "running", "kinesis": "running", "kms": "running", "lambda": "running", "logs": "running", "redshift": "running", "route53": "running", "s3": "running", "secretsmanager": "running", "ses": "running", "sns": "running", "sqs": "running", "ssm": "running", "events": "running", "stepfunctions": "running", "swf": "running", "resourcegroupstaggingapi": "running", "resource-groups": "running", "support": "running", "acm": "running"}, "features": {"persistence": "disabled", "initScripts": "initialized"}}

ValueError: Method eth_maxPriorityFeePerGas not supported, web3.py with ganache

I'm running the following code with web3.py:
transaction = SimpleStorage.constructor().buildTransaction(
{"chainId": chain_id, "from": my_address, "nonce": nonce}
)
And I am running into the following error:
Traceback (most recent call last):
File "/Users/patrick/code/web3_py_simple_storage/deploy.py", line 64, in <module>
transaction = SimpleStorage.constructor().buildTransaction(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/eth_utils/decorators.py", line 18, in _wrapper
return self.method(obj, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/web3/contract.py", line 684, in buildTransaction
return fill_transaction_defaults(self.web3, built_transaction)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/web3/_utils/transactions.py", line 121, in fill_transaction_defaults
default_val = default_getter(web3, transaction)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/web3/_utils/transactions.py", line 71, in <lambda>
web3.eth.max_priority_fee + (2 * web3.eth.get_block('latest')['baseFeePerGas'])
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/web3/eth.py", line 549, in max_priority_fee
return self._max_priority_fee()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/web3/module.py", line 57, in caller
result = w3.manager.request_blocking(method_str,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/web3/manager.py", line 198, in request_blocking
return self.formatted_response(response,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/web3/manager.py", line 171, in formatted_response
raise ValueError(response["error"])
ValueError: {'message': 'Method eth_maxPriorityFeePerGas not supported.', 'code': -32000, 'data': {'stack': 'Error: Method eth_maxPriorityFeePerGas not supported.\n at GethApiDouble.handleRequest (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/lib/subproviders/geth_api_double.js:70:16)\n at next (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:136:18)\n at GethDefaults.handleRequest (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/lib/subproviders/gethdefaults.js:15:12)\n at next (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:136:18)\n at SubscriptionSubprovider.FilterSubprovider.handleRequest (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/subproviders/filters.js:89:7)\n at SubscriptionSubprovider.handleRequest (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/subproviders/subscriptions.js:137:49)\n at next (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:136:18)\n at DelayedBlockFilter.handleRequest (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/lib/subproviders/delayedblockfilter.js:31:3)\n at next (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:136:18)\n at RequestFunnel.handleRequest (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/lib/subproviders/requestfunnel.js:32:12)\n at next (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:136:18)\n at Web3ProviderEngine._handleAsync (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:123:3)\n at Timeout._onTimeout (/Applications/Ganache.app/Contents/Resources/static/node/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:107:12)\n at listOnTimeout (internal/timers.js:531:17)\n at processTimers (internal/timers.js:475:7)', 'name': 'Error'}}
How do I fix this?
This is an issue from a new edition of web3.py.
You need to add gasPrice to your transaction, like so:
transaction = SimpleStorage.constructor().buildTransaction(
{"chainId": chain_id, "gasPrice": w3.eth.gas_price, "from": my_address, "nonce": nonce}
)
This is due to EIP1559 changing, and web3.py updating for the change.

Typeerror: view.getcontroller

Error:
Odoo Server Error
Traceback (most recent call last):
File "F:\odoo-14.0\odoo-14.0\odoo\tools\convert.py", line 677, in _tag_root
f(rec)
File "F:\odoo-14.0\odoo-14.0\odoo\tools\convert.py", line 655, in _tag_template
return self._tag_record(record)
File "F:\odoo-14.0\odoo-14.0\odoo\tools\convert.py", line 580, in _tag_record
record = model._load_records([data], self.mode == 'update')
File "F:\odoo-14.0\odoo-14.0\odoo\models.py", line 4213, in _load_records
records = self._load_records_create([data['values'] for data in to_create])
File "F:\odoo-14.0\odoo-14.0\odoo\models.py", line 4142, in _load_records_create
return self.create(values)
File "<decorator-gen-43>", line 2, in create
File "F:\odoo-14.0\odoo-14.0\odoo\api.py", line 345, in _model_create_multi
return create(self, arg)
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_ui_view.py", line 482, in create
return super(View, self).create(vals_list)
File "<decorator-gen-65>", line 2, in create
File "F:\odoo-14.0\odoo-14.0\odoo\api.py", line 345, in _model_create_multi
return create(self, arg)
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_fields.py", line 534, in create
recs = super().create(vals_list)
File "<decorator-gen-13>", line 2, in create
File "F:\odoo-14.0\odoo-14.0\odoo\api.py", line 345, in _model_create_multi
return create(self, arg)
File "F:\odoo-14.0\odoo-14.0\odoo\models.py", line 3903, in create
fields[0].determine_inverse(batch_recs)
File "F:\odoo-14.0\odoo-14.0\odoo\fields.py", line 1185, in determine_inverse
getattr(records, self.inverse)()
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_ui_view.py", line 300, in _inverse_arch
view.write(data)
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_ui_view.py", line 500, in write
res = super(View, self).write(self._compute_defaults(vals))
File "F:\odoo-14.0\odoo-14.0\odoo\models.py", line 3687, in write
real_recs._validate_fields(vals, inverse_fields)
File "F:\odoo-14.0\odoo-14.0\odoo\models.py", line 1266, in _validate_fields
check(self)
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_ui_view.py", line 411, in _check_xml
)).with_traceback(e.__traceback__) from None
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_ui_view.py", line 385, in _check_xml
view_def = view.read_combined(['arch'])
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_ui_view.py", line 809, in read_combined
arch = root.apply_view_inheritance(arch_tree, self.model)
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_ui_view.py", line 750, in apply_view_inheritance
return self._apply_view_inheritance(source, inherit_tree)
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_ui_view.py", line 758, in _apply_view_inheritance
source = view.apply_inheritance_specs(source, arch_tree)
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_ui_view.py", line 735, in apply_inheritance_specs
self.handle_view_error(str(e))
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_ui_view.py", line 673, in handle_view_error
raise ValueError(formatted_message).with_traceback(from_traceback) from from_exception
odoo.exceptions.ValidationError: Error while validating view:
Element '<xpath expr="//script[last()]">' cannot be located in parent view
View name: QUnit Assets
Error context:
view: ir.ui.view(1033,)
xmlid: qunit_suite
view.parent: ir.ui.view(199,)
file: f:\odoo-14.0\odoo-14.0\custom\muk_web_utils\template\assets.xml
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "F:\odoo-14.0\odoo-14.0\odoo\http.py", line 684, in dispatch
result = self._call_function(**self.params)
File "F:\odoo-14.0\odoo-14.0\odoo\http.py", line 360, in _call_function
return checked_call(self.db, *args, **kwargs)
File "F:\odoo-14.0\odoo-14.0\odoo\service\model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "F:\odoo-14.0\odoo-14.0\odoo\http.py", line 348, in checked_call
result = self.endpoint(*a, **kw)
File "F:\odoo-14.0\odoo-14.0\odoo\http.py", line 913, in __call__
return self.method(*args, **kw)
File "F:\odoo-14.0\odoo-14.0\odoo\http.py", line 532, in response_wrap
response = f(*args, **kw)
File "f:\odoo-14.0\odoo-14.0\addons\web\controllers\main.py", line 1393, in call_button
action = self._call_kw(model, method, args, kwargs)
File "f:\odoo-14.0\odoo-14.0\addons\web\controllers\main.py", line 1381, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "F:\odoo-14.0\odoo-14.0\odoo\api.py", line 396, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "F:\odoo-14.0\odoo-14.0\odoo\api.py", line 383, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-72>", line 2, in button_immediate_install
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_module.py", line 74, in check_and_log
return method(self, *args, **kwargs)
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_module.py", line 475, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "F:\odoo-14.0\odoo-14.0\odoo\addons\base\models\ir_module.py", line 593, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "F:\odoo-14.0\odoo-14.0\odoo\modules\registry.py", line 89, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "F:\odoo-14.0\odoo-14.0\odoo\modules\loading.py", line 460, in load_modules
loaded_modules, update_module, models_to_check)
File "F:\odoo-14.0\odoo-14.0\odoo\modules\loading.py", line 348, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "F:\odoo-14.0\odoo-14.0\odoo\modules\loading.py", line 221, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package)
File "F:\odoo-14.0\odoo-14.0\odoo\modules\loading.py", line 69, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind)
File "F:\odoo-14.0\odoo-14.0\odoo\tools\convert.py", line 733, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate)
File "F:\odoo-14.0\odoo-14.0\odoo\tools\convert.py", line 799, in convert_xml_import
obj.parse(doc.getroot())
File "F:\odoo-14.0\odoo-14.0\odoo\tools\convert.py", line 719, in parse
self._tag_root(de)
File "F:\odoo-14.0\odoo-14.0\odoo\tools\convert.py", line 685, in _tag_root
)) from e
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "F:\odoo-14.0\odoo-14.0\odoo\http.py", line 640, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "F:\odoo-14.0\odoo-14.0\odoo\http.py", line 316, in _handle_exception
raise exception.with_traceback(None) from new_cause
odoo.tools.convert.ParseError: while parsing None:73, near
<data name="QUnit Assets" inherit_id="web.qunit_suite">
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="/muk_web_utils/static/tests/fields.js"/>
</xpath>
</data>
and here is my code:
/**********************************************************************************
*
* Copyright (c) 2017-2019 MuK IT GmbH.
*
* This file is part of MuK Web Utils
* (see https://mukit.at).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
**********************************************************************************/
odoo.define('muk_web_utils.tests.fields', function (require) {
"use strict";
var basicFields = require('web.basic_fields');
var concurrency = require('web.concurrency');
var config = require('web.config');
var core = require('web.core');
var FormView = require('web.FormView');
var KanbanView = require('web.KanbanView');
var ListView = require('web.ListView');
var session = require('web.session');
var testUtils = require('web.test_utils');
var field_registry = require('web.field_registry');
var createView = testUtils.createView;
var createAsyncView = testUtils.createAsyncView;
var DebouncedField = basicFields.DebouncedField;
var JournalDashboardGraph = basicFields.JournalDashboardGraph;
var _t = core._t;
QUnit.module('muk_web_utils', {}, function () {
QUnit.module('fields', {
beforeEach: function () {
this.data = {
partner: {
fields: {
display_name: {
string: "Displayed name",
type: "char",
searchable: true
},
short: {
string: "Short",
type: "char",
searchable: true,
trim: true
},
long: {
String: "Long",
string: "txt",
type: "text",
},
document: {
string: "Binary",
type: "binary",
attachment: true,
},
},
records: [{
id: 1,
display_name: "first record",
short: "Short Text",
long: "Super looooooong Text",
document: 'coucou==\n',
}],
},
};
}
}, function () {
QUnit.module('BinaryFileCopy');
QUnit.test('Fields is correctly rendered', function (assert) {
assert.expect(2);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: (
'<form string="Partners">' +
'<field name="document" widget="copy_binary" filename="short"/>' +
'<field name="short"/>' +
'</form>'
),
res_id: 1,
});
assert.strictEqual(
form.$('a.o_field_widget[name="document"] > .mk_copy_binary > .mk_copy_button').length,
1, "the copy button should be visible in readonly mode"
);
form.$buttons.find('.o_form_button_edit').click();
assert.strictEqual(
form.$('a.o_field_widget[name="document"] > .mk_copy_binary').length,
0, "the copy button shouldn't be visible in edit mode"
);
form.destroy();
});
QUnit.module('CharShare');
QUnit.test('Fields is correctly rendered', function (assert) {
assert.expect(1);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: (
'<form string="Partners">' +
'<div>' +
'<field name="short" widget="share_char"/>' +
'</div>' +
'</form>'
),
res_id: 1,
});
assert.strictEqual(
form.$('span.o_field_widget[name="short"] > .mk_share_dropdown.mk_share_char').length,
1, "the copy button should be visible in readonly mode"
);
form.destroy();
});
QUnit.module('TextShare');
QUnit.test('Fields is correctly rendered', function (assert) {
assert.expect(1);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: (
'<form string="Partners">' +
'<div>' +
'<field name="long" widget="share_text"/>' +
'</div>' +
'</form>'
),
res_id: 1,
});
assert.strictEqual(
form.$('span.o_field_widget[name="long"] > .mk_share_dropdown.mk_share_text').length,
1, "the copy button should be visible in readonly mode"
);
form.destroy();
});
QUnit.module('BinaryFileShare');
QUnit.test('Fields is correctly rendered', function (assert) {
assert.expect(2);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: (
'<form string="Partners">' +
'<field name="document" widget="share_binary" filename="short"/>' +
'<field name="short"/>' +
'</form>'
),
res_id: 1,
});
assert.strictEqual(
form.$('a.o_field_widget[name="document"] > .mk_share_dropdown > .mk_share_button').length,
1, "the share dropdown should be visible in readonly mode"
);
form.$buttons.find('.o_form_button_edit').click();
assert.strictEqual(
form.$('a.o_field_widget[name="document"] > .mk_share_dropdown > .mk_share_button').length,
0, "the share dropdown shouldn't be visible in edit mode"
);
form.destroy();
});
});
});
});
When i upgrade this module from odoo 12 to odoo 14 then this error occured.When I changed the xpath and install this module its show an error typerror:view.getcontroller(....)then.guardedcatch is not a function. I have no idea about this error how can i fix it and in my code where i need to change please help me.
<xpath expr="//script[last()]" position="after">
Odoo can't able to get the above expr path so please check your inherited_id in v14.
or try to rewrite as this:
<template id="qunit_suite" name="QUnit Assets" inherit_id="web.qunit_suite">
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="/muk_web_utils/static/tests/fields.js" />
</xpath>
</template>

ValueError: Invalid field u'field' in leaf "<osv.ExtendedLeaf: (u'field', u'in', [59]) on object (ctx: )>" - Odoo v8

I have these methods:
#api.depends('order_lines', 'order_lines.isbn')
def _get_products(self):
isbn = self.env['product.product']
for prodtmpl in self.order_lines:
isbn |= prodtmpl.isbn
return isbn
#api.model
def _get_act_window_dict(self, name):
mod_obj = self.env['ir.model.data']
result = mod_obj.xmlid_to_object(name)
if not result:
result = {
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'stock.quant',
'name': 'Stock On Hand',
'type': 'ir.actions.act_window',
}
else:
result = result[0].read()[0]
return result
#api.multi
def action_open_isbn(self):
isbn = self._get_products()
result = self._get_act_window_dict('stock.product_open_quants')
result['domain'] = "[('isbn','in',[" + ','.join(map(str, isbn.ids)) + "])]"
result['context'] = "{'search_default_locationgroup': 1, 'search_default_internal_loc': 1}"
return result
On method get_act_window_dict it should return products on quants, like on Qty On Hand from product.template
But it throws me this:
Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\http.py", line 546, in _handle_exception
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\http.py", line 583, in dispatch
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\http.py", line 319, in _call_function
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\service\model.py", line 118, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\http.py", line 316, in checked_call
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\http.py", line 812, in __call__
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\http.py", line 412, in response_wrap
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\openerp\addons\web\controllers\main.py", line 944, in call_kw
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\openerp\addons\web\controllers\main.py", line 936, in _call_kw
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\openerp\addons\stock\stock.py", line 331, in read_group
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\models.py", line 2082, in read_group
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\api.py", line 268, in wrapper
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\models.py", line 4498, in _where_calc
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\osv\expression.py", line 662, in __init__
File "C:\Program Files (x86)\Odoo 8.0-20170914\server\.\openerp\osv\expression.py", line 830, in parse
ValueError: Invalid field u'isbn' in leaf "<osv.ExtendedLeaf: (u'isbn', u'in', [59]) on stock_quant (ctx: )>"
I've tried doing this:
#api.model
def _get_act_window_dict(self, name):
mod_obj = self.env['ir.model.data']
result = mod_obj.xmlid_to_object(name)
if not result:
result = {
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'stock.quant',
'name': 'Stock On Hand',
'isbn': 'product_id',
'type': 'ir.actions.act_window',
}
else:
result = result[0].read()[0]
return result
Adding isbn to the dict result as product_id but same result.
So, any ideas?
PS: This is isbn field on my class:
isbn = fields.Many2one('product.product', string="ISBN", domain="[('is_isbn', '=', True)]")
Of course it doesn't exist as isbn on stock.quant but it's a Many2one to product so it should pass somehow.
This line:
result['domain'] = "[('isbn','in',[" + ','.join(map(str, isbn.ids)) + "])]"
should be:
result['domain'] = "[('product_id','in',[" + ','.join(map(str, isbn.ids)) + "])]"
No field isbn in stock.quant. Since isbn is object product.product, I think it's just the same with product_id of stock.quant

Django MySql InternalError: (-1, 'server not initialized')

I have had this working, a few months ago, but apparently I phases of the moon changed or something.
I have MySQL-python installed.
And I only get this error when running manage.py shell and then trying to make db queries. When I add or remove items from the /admin/ interface then it doesn't seem to have any troubles.
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/models/manager.py", line 151, in get
return self.get_queryset().get(*args, **kwargs)
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/models/query.py", line 301, in get
num = len(clone)
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/models/query.py", line 77, in __len__
self._fetch_all()
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/models/query.py", line 854, in _fetch_all
self._result_cache = list(self.iterator())
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/models/query.py", line 220, in iterator
for row in compiler.results_iter():
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 710, in results_iter
for rows in self.execute_sql(MULTI):
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 780, in execute_sql
cursor = self.connection.cursor()
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/backends/__init__.py", line 157, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/backends/__init__.py", line 129, in _cursor
self.ensure_connection()
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/backends/__init__.py", line 124, in ensure_connection
self.connect()
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/backends/__init__.py", line 124, in ensure_connection
self.connect()
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/backends/__init__.py", line 112, in connect
self.connection = self.get_new_connection(conn_params)
File "/home2/univetg1/python27/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 435, in get_new_connection
conn = Database.connect(**conn_params)
File "/home2/univetg1/python27/lib/python2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/home2/univetg1/python27/lib/python2.7/site-packages/MySQLdb/connections.py", line 179, in __init__
client_version = tuple([ numeric_part(n) for n in _mysql.get_client_info().split('.')[:2] ])
InternalError: (-1, 'server not initialized')
my db settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'db',
'USER': 'user',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '3306',
}
}

Categories

Resources