tinyerp / erppeek Goto Github PK
View Code? Open in Web Editor NEWA versatile tool for Odoo / OpenERP. *** Forked as Odooly ⟶
Home Page: https://github.com/tinyerp/odooly
License: Other
A versatile tool for Odoo / OpenERP. *** Forked as Odooly ⟶
Home Page: https://github.com/tinyerp/odooly
License: Other
This traceback:
>>> model('res.partner').browse([1, 1]).read()
Traceback (most recent call last):
File "/srv/openerp/.buildout/eggs/ERPpeek-1.4.5-py2.6.egg/erppeek.py", line 1402, in runcode
_exec(code, globals())
File "/srv/openerp/.buildout/eggs/ERPpeek-1.4.5-py2.6.egg/erppeek.py", line 1364, in _exec
exec('exec code in g')
File "<string>", line 1, in <module>
File "<console>", line 1, in <module>
File "/srv/openerp/.buildout/eggs/ERPpeek-1.4.5-py2.6.egg/erppeek.py", line 1374, in displayhook
_printer(value)
File "/usr/lib/python2.6/pprint.py", line 56, in pprint
printer.pprint(object)
File "/usr/lib/python2.6/pprint.py", line 114, in pprint
self._format(object, self._stream, 0, 0, {}, 0)
File "/usr/lib/python2.6/pprint.py", line 137, in _format
rep = self._repr(object, context, level - 1)
File "/usr/lib/python2.6/pprint.py", line 230, in _repr
self._depth, level)
File "/usr/lib/python2.6/pprint.py", line 242, in format
return _safe_repr(object, context, maxlevels, level)
File "/usr/lib/python2.6/pprint.py", line 318, in _safe_repr
orepr, oreadable, orecur = _safe_repr(o, context, maxlevels, level)
File "/usr/lib/python2.6/pprint.py", line 286, in _safe_repr
vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level)
File "/usr/lib/python2.6/pprint.py", line 327, in _safe_repr
rep = repr(object)
File "/srv/openerp/.buildout/eggs/ERPpeek-1.4.5-py2.6.egg/erppeek.py", line 1226, in __repr__
return "<Record '%s,%d'>" % (self._model_name, self.id)
TypeError: %d format: a number is required, not Record
This is an indeed a good library :)
But I have 2 problems.
a) Right now, all my openerp is running behind nginx.
example,
instead of
http://myerpdomain.com:8069 (i don't want people to access this).
What should I do to make this work?
b) What if all my sites are behind HTTPS too? What would be the recommended settings?
Hopefully the above 2 are supported. Thanks.
>>> client.install('base')
Module(s) not found: base
>>> 'base' in client.modules('base')['installed']
True
Currently we get (from README.rst
):
$ erppeek -d demo -m res.partner -f name -f lang 1
[{'id': 1, 'lang': 'en_US', 'name': 'Your Company'}]
$ erppeek -d demo -m res.groups -f full_name 'id > 0'
[{'full_name': 'Administration / Access Rights', 'id': 1},
{'full_name': 'Administration / Configuration', 'id': 2},
{'full_name': 'Human Resources / Employee', 'id': 3},
{'full_name': 'Usability / Multi Companies', 'id': 4},
{'full_name': 'Usability / Extended View', 'id': 5},
{'full_name': 'Usability / Technical Features', 'id': 6},
{'full_name': 'Sales Management / User', 'id': 7},
{'full_name': 'Sales Management / Manager', 'id': 8},
{'full_name': 'Partner Manager', 'id': 9}]
But it would be better to have something tabular or CSV compatible.
After creating a new database in OpenERP, I didn't use the same password as i always use.
ERPPeek didn't tell me the password was wrong until i was trying to create an object with Client.
Traceback (most recent call last):
File "lib/python2.7/site-packages/django/core/handlers/base.py", line 114, in get_response
response = wrapped_callback(request, _callback_args, *_callback_kwargs)
File "decorators.py", line 42, in convert
return func(request, _args, *_kwargs)
File "decorators.py", line 22, in _wrapped_view
return view_func(request, _args, *_kwargs)
File "offers.py", line 348, in offer_creation
request.FILES)
File "offers.py", line 423, in create_offer_db
offer_id = erp.Client.create('product.product', offer_data)
File "erppeek.py", line 894, in wrapper
return self.execute(obj, method, _params, *_kwargs)
File "erppeek.py", line 636, in execute
res = self._execute(obj, method, *params)
TypeError: 'NoneType' object is not callable
After putting a few pdbs in the code, I realised that self._execute was still None because the function called "authenticated" defined in login returned None instead of raising an error ?
It could detect the Odoo/OpenERP configuration, and load the local mode in this case.
The error happens on the server side.
It could be a bug in OpenERP.
>>> model('res.currency').get(1).rate_ids
2013-02-28 10:56:47,103 22484 ERROR behave openerp.osv.osv: Uncaught exception
Traceback (most recent call last):
File "/vagrant/demo/src/server/openerp/osv/osv.py", line 140, in wrapper
return f(self, dbname, *args, **kwargs)
File "/vagrant/demo/src/server/openerp/osv/osv.py", line 200, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/vagrant/demo/src/server/openerp/osv/osv.py", line 188, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/vagrant/demo/src/server/openerp/addons/base/res/res_currency.py", line 103, in read
rates=r['rate_ids']
TypeError: string indices must be integers, not str
while calling object.execute('behave', 1, u'res.currency', 'read', 1, ['rate_ids'])
This modified syntax works:
>>> model('res.currency').browse([1]).rate_ids
[<RecordList 'res.currency.rate,[1]'>]
Is it possible to export records as serialiesed XML for openerp/data-records or template?
In version 1.5 the prompt was printing the environment name.
In version 1.6 beta the prompt never prints the environment name, but prints the database name instead.
The previous behavior should be restored.
Hello,
The function start_openerp_services does not work with version 7. It seems the function to call is the start_internal instead of start_web_service. I do not know how to manage the version problematic.
Regards
Nicolas
Currently when the attribute is empty, it returns an empty list. It should return an empty RecordList of the relevant model.
This typically happens when you call a workflow function and want to check the new state of the object.
I'm very happy I just bumped into this project. I'm also a very happy IPython user.
Is there a way to get erppeek inside ipython? (or vice versa)
>>> model('res.users').browse([1, 42421]).login
Traceback (most recent call last):
File "erppeek.py", line 1390, in runcode
_exec(code, globals())
File "<console>", line 1, in <module>
File "erppeek.py", line 1164, in __getattr__
return self.read(attr, context=context)
File "erppeek.py", line 1108, in read
fields, order=True, context=context)
File "erppeek.py", line 775, in read
res = self.execute(obj, 'read', *params, **kwargs)
File "erppeek.py", line 635, in execute
assert len(res) == len(set(ids))
AssertionError
Hello,
I noticed the following comment in erppeek.py
:
# Supported operators are
# =, !=, >, >=, <, <=, like, ilike, in,
# not like, not ilike, not in, child_of
# Not supported operators are
# - redundant operators: '<>', '=like', '=ilike'
# - future operator(s) (6.1): '=?'
The operators '=like' and '=ilike' are not redundant.
The like and ilike operators in OpenERP automatically add % characters around the value, while the =like and =ilike do not.
Examples with the OpenERP domain's criteria and the result in SQL:
[('name', 'like', 'Behave')] =>
name LIKE '%Behave%'
[('name', 'like', 'Behave%')] =>
name LIKE '%Behave%%'
[('name', '=like', 'Behave')] =>
name LIKE 'Behave' (no sense to use it like this)
[('name', '=like', 'Behave%')] =>
name LIKE 'Behave%' (with =like, we can control more finely the criteria)
I think it's worth adding them.
Also, here is an explanation of the '=?' mysterious operator : http://openerp-server.git.sourceforge.net/git/gitweb.cgi?p=openerp-server/openerp-server;a=commitdiff;h=046b44c3ce2677b64eda0c407984e9872efddd1b
Copy / paste for the record:
P. Christeas:
In some cases, when the domain is restricted based on an optional field,
we want it to match anything if that field is not set. There, use the
'=?' operator to match "left = right OR right IS NULL/False".eg. match the production lot among all products, when product is not
specified (helps barcode scanners pick up the serial no.).
It was introduced in version 6.0.
Guewen
Hi there,
We are using ERPpeek in a project and it's being wonderful, thanks.
The library is executed in celery tasks, basically background tasks. We have a 300 second hard time limit set in celery that kills the process after that time. It's something you really don't want to see kicking in and apparently the tasks using ERPpeek are reaching the limit easily. This is due to OpenERP rpc api not responding in a timely fashion and also we are not seeing any timeouts, neither mentions to the topic within docs.
is there a way to set a timeout for ERPpeek calls?
Thanks, cheers
Miguel
currently the only way to send a signal to a Record
is:
invoice = model("account.invoice").browse(42)
client.exec_workflow("account.invoice", "invoice_open", invoice.id)
We need probably something like Record._send(signal)
.
The method could be in the private namespace _
to avoid conflict with any field or osv method.
We should have a short tutorial in the documentation to describe the easier Model/Record API.
Hi,
do you think it would make sense to store somewhere (e.g. the Client instance) the current global context?
Then, for example, Client.create(), when not supplied a context, could use the global one.
The practical case where this came up is the oerpscenario cucumber-like framework, where a global context could allow a better solution than
https://code.launchpad.net/~camptocamp/oerpscenario/trunk-set-context-lep/+merge/223207
to make a step that sets the openerp context.
I gave a look to your similar project mirliton and it looks like also there there isn't a step to set the context.
Thanks!
Hi,
In v1.6b1, start_openerp_services function becomes start_odoo_services.
A tool as OERPScenario still uses the function start_openerp_services.
Is it possible to keep a double compatibility with openerp and odoo?
Or do you recommend to stay on v1.5.7 for OpenERPv7?
thanks,
Romain
I need some help. I need to get the account_id tied to the product.
This is my code.
demo >>> contracts_proxy = model('account.analytic.account')
demo >>> contracts = contracts_proxy.browse([])
demo >>> contracts
<RecordList 'account.analytic.account,length=63'>
demo >>> print contracts[0].contract_line[0]
tenant.contract.line,28
demo >>> print contracts[0].contract_line[0].product_id
Monthly Room Rental
demo >>> print contracts[0].contract_line[0].product_id.property_account_income.id
When I ran the last line, I got this error
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/erppeek.py", line 1499, in runcode
_exec(code, global_vars)
File "/Library/Python/2.7/site-packages/erppeek.py", line 1464, in _exec
exec('exec code in g')
File "<string>", line 1, in <module>
File "<console>", line 1, in <module>
AttributeError: 'bool' object has no attribute 'id'
Any idea?
In OpenERP 7, the value for account id is from product_id.property_account_income.id. But in erppeek, can't get this to work?
Any help? Thanks.
There's nothing specific for on_change events in ERPpeek.
The way to mimic the OpenERP client (6.1) is:
# on_change with ERPpeek for invoice creation
@step('this customer has {nb:d} invoices')
def impl(ctx, nb):
assert_true(ctx.data['partner'])
partner = ctx.data['partner']
account_invoice_obj = model('account.invoice')
for idx in xrange(1, nb + 1):
# On change
data = {
'name': "Invoice # %d" % idx,
'type': "out_invoice",
'address_invoice_id': partner.address[0].id,
'partner_id': partner.id,
}
rv = account_invoice_obj.onchange_partner_id([], 'out_invoice', partner.id, date.today(), False, False)
data.update(rv['value'])
inv = account_invoice_obj.create(data)
if partner.contract_ids:
inv.write({'contract_id': partner.contract_ids[0].id})
ctx.data['invoice'] = inv
To be added to the documentation.
With ERPpeek 1.5.1, this is unsafe to compare records from different databases: if the model name and the id are the same, the comparison returns True.
It should return False if the Record._model.client
is different.
>>> client.modules('base')
defaultdict(<type 'list'>, {'installed': ['base', 'base_iban', 'base_setup', 'base_tools', 'base_vat']})
This should be cast to dict before printing.
When using Record.perm_read
passing a single id
, it returns an IndexError: list index out of range
.
This happens with erppeek v 0.10 and server 5.0.
For instance:
>>> client.upgrade('no_such_module')
11 module(s)
>>>
I expected an error message mentioning that there is no such module.
I noticed that some methods are expecting list of ids instead of single id.
We might switch automatically to a list of 1 id for the Record
methods.
>>> model('account.fiscalyear').browse(42).create_period()
<Error>
>>> model('wizard.multi.charts.accounts').browse(42).execute()
<Error>
like to check.
Let's say I am looping through 10 records and creating invoices. Let's say until the 7th invoice, network is down. Is there a way to trigger rollback (aka undo?) in erppeek?
Any help? Thanks.
It would be nice to have a method client.get_object(xml_id)
to retrieve an object by xml_id.
The implementation is relatively simple:
def get_object(xml_id):
"""Return the record referenced by this xml_id."""
module, name = xml_id.split('.')
search_domain = [('module', '=', module), ('name', '=', name)]
data = model('ir.model.data').read(search_domain, 'model res_id')
if data:
assert len(data) == 1
return model(data[0]['model']).get(data[0]['res_id'])
It would be convenient to compare records without explicitly comparing ids.
>>> company = model('res.company').get(1)
>>> main_company = model('res.company').get('base.main_company')
>>> main_company == company
False
the normal RPC mode is not affected.
$ erppeek --env +openerp
Traceback (most recent call last):
File "/usr/local/bin/erppeek", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/erppeek.py", line 1565, in main
client = Client.from_config(args.env, verbose=args.verbose)
File "/usr/local/lib/python2.7/dist-packages/erppeek.py", line 430, in from_config
server = start_openerp_services(server[1], appname=appname)
File "/usr/local/lib/python2.7/dist-packages/erppeek.py", line 238, in start_openerp_services
if not openerp.osv.osv.service:
AttributeError: 'module' object has no attribute 'service'
For instance:
./erppeek.py --server=https://server:443/ --user=admin -p XX --db=YY
fails with:
xmlrpclib.ProtocolError: <ProtocolError for server:443//xmlrpc/db: 404 NOT FOUND>
Removing the trailing / in the URI works
>>> empty_list = model('res.company').browse(['id < 0'])
>>> empty_list
<RecordList 'res.company,[]'>
>>> empty_list.name
[]
>>> empty_list.name_get()
[[1, 'Odoo']]
In odoo 8.0 db.create changed signature to db.create_database
Captured logging:
ERROR:openerp.http:exp_create
Traceback (most recent call last):
File ".../server/openerp/http.py", line 93, in dispatch_rpc
result = dispatch(method, params)
File ".../server/openerp/service/db.py", line 69, in dispatch
fn = globals()['exp_' + method]
KeyError: 'exp_create'
I have difficulty making this worked. Creating products, no problems.
I have 1000 products right now in OpenERP v7. But when comes to update the product quantity (via qty_available), I can't. The field is read-only. Checking the model (code level, it's a function). It's not a column inside the product_product table.
Do you have any suggestions on how could I update a product with the available quantity?
I hope this can be done on script level. Else I have to manually update 1 by 1, kinda nightmare.
Any help? Thanks.
ERPpeek cannot connect through HTTPS
Like to check how much I could do with erppeek? Is it production ready?
Can I create a new draft quotation, then send for approval, etc?
Same to invoices creation?
Any help? Thanks.
Hi there,
Like to check. Wonder you can assist me.
Here's my code.
import erppeek
import time
from datetime import date
client = erppeek.Client.from_config('demo')
contracts_proxy = client.model('account.analytic.account')
contracts = contracts_proxy.browse([])
account_invoice_obj = client.model('account.invoice')
invoice_data = {
'partner_id' : contracts[10].partner_id.id,
'analytic_id' : contracts[10].id,
'mobile' : '',
}
account_invoice_request = account_invoice_obj.onchange_partner_id([], 'out_invoice', contracts[10].partner_id.id, str(date.today()), False, False)
invoice_data.update(account_invoice_request['value'])
invoice = account_invoice_obj.create(invoice_data)
invoice.write( {'date_invoice' : str(date.today()) })
invoice.write( {'date_to' : str(date.today()) })
The above codes worked fine as I could create the invoice.
Right after that code, I have these codes.
account_invoice_line_obj = client.model('account.invoice.line')
for index in range(len(contracts[10].contract_line)):
invoice_line_data = {
'invoice_id' : invoice.id,
'name' : '',
}
account_invoice_line_request = account_invoice_line_obj.onchange_product_id(contracts[10].contract_line[index].product_id.id, contracts[10].partner_id.id, contracts[10].id, 0, [])
invoice_line_data.update(account_invoice_line_request['value'])
invoice_line = account_invoice_line_obj.create(invoice_line_data)
invoice_line.write( {'product_id' : contracts[10].contract_line[index].product_id.id })
invoice_line.write( {'price_unit' : contracts[10].contract_line[index].charge })
Example, Contract A is tied to Client A. Contract B is tied to Client B.
For contracts[10], it's referring to Contract A.
In each Contract, there are services tied to them.
There's ongoing services like
Now's the problem.
When I did this:-
print contracts[10].contract_line[index].product_id
it shows "monthly rental"
however when I ran this code below
account_invoice_line_request = account_invoice_line_obj.onchange_product_id(
contracts[10].contract_line[index].product_id.id,
contracts[10].partner_id.id,
contracts[10].id,
0,
[])
It showed up as "Monthly water bills". But the pricing of price_unit is showing up correctly.
This is the output I got
Wonder what did I do wrong? or is this a bug for erppeek?
Any help? Thanks.
When I run:
erppeek --server=https://xxx.odoo.com/ -uguewen.baconnier -dxxx -v
I obtain:
--> db.server_version()
<-- 7.saas~3
--> db.list()
Traceback (most recent call last):
File "/usr/local/bin/erppeek", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/erppeek.py", line 1568, in main
verbose=args.verbose)
File "/usr/local/lib/python2.7/dist-packages/erppeek.py", line 417, in __init__
self._login(user, password=password, database=db)
File "/usr/local/lib/python2.7/dist-packages/erppeek.py", line 449, in login
dbs = self.db.list()
File "/usr/local/lib/python2.7/dist-packages/erppeek.py", line 361, in wrapper
res = self._dispatch(name, args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1578, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python2.7/xmlrpclib.py", line 1297, in single_request
return self.parse_response(response)
File "/usr/lib/python2.7/xmlrpclib.py", line 1473, in parse_response
return u.close()
File "/usr/lib/python2.7/xmlrpclib.py", line 793, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault AccessDenied: 'Access denied.'>
It seems that db.list()
is blocked on the online servers.
Here is the workaround I found:
import erppeek
c = erppeek.Client('https://xxx.odoo.com/')
c._db = 'xxx'
c.login('guewen.baconnier', password='xxx')
Is the call to db.list()
really necessary? If yes, what should be the best way to handle this error?
Currently the date is not parsed correctly if you omit quotes.
>>> model('res.partner').browse(['create_date > "2001-12-31 23:59:00"'])
<RecordList 'res.partner,length=1467'>
>>> model('res.partner').browse(['create_date > 2001-12-31 23:59:00'])
<RecordList 'res.partner,length=1467'>
>>> model('res.partner').browse(['create_date > "2001-12-31"'])
<RecordList 'res.partner,length=1467'>
>>> model('res.partner').browse(['create_date > 2001-12-31'])
ProgrammingError: operator does not exist: timestamp without time zone > integer
LINE 1: ...ctive" = 'True') AND (res_partner."create_date" > 1958)) O...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Regression of 1.6b1 when switching the environment with client.connect("other_section")
We could work around Python bug http://bugs.python.org/issue20611 in the library.
See also: http://stackoverflow.com/a/14262151
In the Tutorial not have a example for creation or update with one2many and many2many records.
This is an optimization available since OpenERP 8.
http://bazaar.launchpad.net/~openerp/openobject-server/trunk/revision/4906
Like to check.
I have ran the codes for install crm as follows:-
#!/usr/bin/env python
from __future__ import print_function
import erppeek
client = erppeek.Client.from_config('demo')
modules = client.modules('crm', installed=False)
if 'crm' in modules['uninstalled']:
client.install('crm')
When I ran that code, I saw this
15 module(s) to process:
to install crm
to install mail
to install oerp_no_phoning_home
to install auth_signup
to install base_action_rule
to install base_calendar
to install base_setup
to install base_status
to install board
to install email_template
to install fetchmail
to install portal
to install portal_crm
to install resource
to install share
But it doesn't show me whether it's success or fail. Unless, I have to manually go into OpenERP and see the install_apps manually. Is there a way to get the status of installation?
Thanks.
Hi,
the Model.browse()
method accepts an integer, a list or a domain. I realized that when passing a list, there is the risk that an empty list is considered as an empty domain and finds all records instead of none.
This looks just a bit confusing because of the different style between openerp and erppeek: the openerp idiom
ids = model.search(domain)
records = model.browse(ids)
should not be translated as is to erppeek because if nothing is found, we get all records.
Instead, in erppeek it could just be written:
records = model.browse(domain)
IMO this issue can be addressed just with an extra remark in the doc.
Thanks!
I have a frequent use case where I need to retrieve a single Record
from a Model
.
The record should be unique for the domain.
Currently it can be done with:
records = model("res.partner").browse(["name = Romeo"])
assert len(records) == 1
record = records[0]
The proposal is to implement a new method Model.get
to retrieve a single record.
If there's more than one record, it raises an error.
I no record, it returns None.
Currently the external_id (a.k.a. xml_id) is retrieved with the other metadata through the perm_read()
call.
This feature adds a helper to set/get the external_id.
For example:
staging >>> model('res.company').browse(42).read()
--> object.execute('stagingdb', 1, '*', 'res.company', 'read', 42, None)
<-- False
Traceback (most recent call last):
File "erppeek.py", line 1261, in runcode
_exec(code, globals())
File "<console>", line 1, in <module>
File "erppeek.py", line 1129, in read
elif '%(' in fields:
TypeError: argument of type 'NoneType' is not iterable
staging >>>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.