tryton-ar / party_ar Goto Github PK
View Code? Open in Web Editor NEWIntegrates party with AFIP
License: GNU General Public License v3.0
Integrates party with AFIP
License: GNU General Public License v3.0
Remove validation. This is a very strict validation, and sometimes we want to have duplicated entitys with the same cuit.
[AFIP] tiene una API tipo REST para obtener datos a partir de una CUIT, CUIL o CDI, lo cual es muy útil para evitar demoras al cargar clientes o proveedores en un sistema de facturación, por ejemplo.
También permite obtener una lista CUILs o CUITs a partir de DNIs.
https://soa.afip.gob.ar/sr-padron/v2/persona/30500010912
https://soa.afip.gob.ar/sr-padron/v1/constancia/30500010912
https://soa.afip.gob.ar/sr-padron/v2/personas/23456789
I think we should improve the vat_number field and has another field like vat_number_format.
This way, vat_number_format will be the one that we use to display and vat_number will be the compact value.
Information at stdnum:
https://arthurdejong.org/python-stdnum/doc/1.8/stdnum.ar.cuit.html
We will need to add the format method. Something similar as CBU format:
https://arthurdejong.org/python-stdnum/doc/1.8/stdnum.ar.cbu.html#stdnum.ar.cbu.format
Right now, goes to country.country model.
The idea is to add a many2one field to afip.country model that exists at company_ar module.
More information:
tryton-ar/account_invoice_ar#96
We have the field TIPO DOCUMENTO. We could improve the set_vat_number so if TIPO_DOCUMENTO says DNI, the value saved to the system could be ar_dni instead of ar_cuit.
Perhaps, instead of improve set_vat_number, we could add a different field to saved the identifier from the header.
La condición ante IVA de una entidad puede cambiar de un momento a otro (por ejemplo, pasar de exento a monotributista o responsable inscripto). Entonces es deseable que esos datos mantenerlos actualizados en nuestro sistema.
Crear un cron que se ejecute cada 15 días para mantener actualizado el dato de la condición ante IVA.
When migrating the afip code of the country are missing several countries.
219 During handling of the above exception, another exception occurred:
220
221 Traceback (most recent call last):
222 File "/usr/lib/python3.9/logging/__init__.py", line 1079, in emit
223 msg = self.format(record)
224 File "/usr/lib/python3.9/logging/__init__.py", line 923, in format
225 return fmt.format(record)
226 File "/usr/lib/python3.9/logging/__init__.py", line 659, in format
227 record.message = record.getMessage()
228 File "/usr/lib/python3.9/logging/__init__.py", line 363, in getMessage
229 msg = msg % self.args
230 TypeError: not enough arguments for format string
231 Call stack:
232 File "/usr/lib/python3.9/threading.py", line 912, in _bootstrap
233 self._bootstrap_inner()
234 File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
235 self.run()
236 File "/usr/lib/python3.9/threading.py", line 892, in run
237 self._target(*self._args, **self._kwargs)
238 File "/opt/trytond/quino/env/lib/python3.9/site-packages/trytond/ir/cron.py", line 184, in run
239 cron.run_once()
240 File "/opt/trytond/quino/env/lib/python3.9/site-packages/trytond/model/descriptors.py", line 31, in newfunc
241 return self.func(owner, [instance], *args, **kwargs)
242 File "/opt/trytond/quino/env/lib/python3.9/site-packages/trytond/model/modelview.py", line 697, in wrapper
243 return func(cls, records, *args, **kwargs)
244 File "/opt/trytond/quino/env/lib/python3.9/site-packages/trytond/modules/company/ir.py", line 109, in run_once
245 super(Cron, cls).run_once([cron])
246 File "/opt/trytond/quino/env/lib/python3.9/site-packages/trytond/model/descriptors.py", line 33, in newfunc
247 return self.func(owner, *args, **kwargs)
248 File "/opt/trytond/quino/env/lib/python3.9/site-packages/trytond/model/modelview.py", line 697, in wrapper
249 return func(cls, records, *args, **kwargs)
250 File "/opt/trytond/quino/env/lib/python3.9/site-packages/trytond/ir/cron.py", line 156, in run_once
251 getattr(Model, method)()
252 File "/opt/trytond/quino/env/lib/python3.9/site-packages/trytond/modules/party_ar/party.py", line 493, in import_cron_afip
253 cls.import_census(args)
254 File "/opt/trytond/quino/env/lib/python3.9/site-packages/trytond/modules/party_ar/party.py", line 484, in import_census
255 logger.error('Could not retrieve "%s" msg AFIP: "%s".',
256 Message: 'Could not retrieve "%s" msg AFIP: "%s".'
257 Arguments: (('30707010211', 'Tu Constancia se encuentra bloqueada. El 30-nov-2018 venció el plazo para constituir el domicilio fiscal electrónico. Constituilo para desbloquearla.'),)
258 Fri Dec 15 11:14:34 2023] INFO:pysimplesoap.client:POST https://aws.afip.gov.ar/sr-padron/webservices/personaServiceA5
The new webservice implemented with ticket #5 brings other information as:
It would be useful to bring this information to the party when click the button AFIP.
The name of the party is what AFIP retrieves. But, sometimes, the name of the party is different of the fantasy name of the customer. So, we think that it would be nice to set the name of the fantasy name at nombre_compania field, and show it into party_list_view.
Traceback (most recent call last):
File "/trytond/protocols/jsonrpc.py", line 162, in _marshaled_dispatch
response['result'] = dispatch_method(method, params)
File "/trytond/protocols/jsonrpc.py", line 191, in _dispatch
res = dispatch(*args)
File "/trytond/protocols/dispatcher.py", line 162, in dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/trytond/wizard/wizard.py", line 275, in execute
return wizard._execute(state_name)
File "/trytond/wizard/wizard.py", line 287, in _execute
view['fields'].keys())
File "/trytond/wizard/wizard.py", line 93, in get_defaults
defaults.update(default(fields))
File "/trytond/modules/party_ar/party.py", line 597, in default_start
'error': ''.join([e['error'] for e in padron.errores]),
AttributeError: 'NoneType' object has no attribute 'errores'
When migrate to 4.0 the module crash
File "/home/luis/tryton/trytond/trytond/modules/party_ar/party.py", line 311, in register
party_row = cursor.dictfetchone()
Error that i get when try to enable the module from Tryton Client
14279 139690265552640 [2016-10-08 09:43:53,110] ERROR trytond.protocols.dispatcher <class 'trytond.ir.module.ir.module.install_upgrade'>.execute((22, {u'start': {u'module_info': u'party_ar: to install', u'id': -48}}, u'upgrade', {u'date_format': u'%m/%d/%Y', u'language': u'en_US', u'locale': {u'date': u'%m/%d/%Y', u'thousands_sep': u',', u'decimal_point': u'.', u'grouping': [3, 3, 0]}, u'language_direction': u'ltr', u'company.rec_name': u'Jose Luis Zanotti', u'active_model': u'ir.module', u'groups': [4, 5, 1, 2, 3, 6], u'action_id': 42, u'employee': None, u'active_ids': [15], u'company': 1, u'active_id': 15}), *{}) from [email protected]//tryton/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/trytond-4.0.4-py2.7.egg/trytond/protocols/dispatcher.py", line 201, in _dispatch
result = rpc.result(meth(_c_args, *_c_kwargs))
File "/usr/local/lib/python2.7/dist-packages/trytond-4.0.4-py2.7.egg/trytond/wizard/wizard.py", line 275, in execute
return wizard._execute(state_name)
File "/usr/local/lib/python2.7/dist-packages/trytond-4.0.4-py2.7.egg/trytond/wizard/wizard.py", line 306, in _execute
result = self._execute(transition())
File "/usr/local/lib/python2.7/dist-packages/trytond-4.0.4-py2.7.egg/trytond/ir/module.py", line 570, in transition_upgrade
pool.init(update=update, lang=lang)
File "/usr/local/lib/python2.7/dist-packages/trytond-4.0.4-py2.7.egg/trytond/pool.py", line 155, in init
lang=lang)
File "/usr/local/lib/python2.7/dist-packages/trytond-4.0.4-py2.7.egg/trytond/modules/init.py", line 434, in load_modules
_load_modules()
File "/usr/local/lib/python2.7/dist-packages/trytond-4.0.4-py2.7.egg/trytond/modules/init.py", line 398, in _load_modules
load_module_graph(graph, pool, update, lang)
File "/usr/local/lib/python2.7/dist-packages/trytond-4.0.4-py2.7.egg/trytond/modules/init.py", line 237, in load_module_graph
cls.register(module)
File "/usr/local/lib/python2.7/dist-packages/trytonar_party_ar-4.0.0-py2.7.egg/trytond/modules/party_ar/party.py", line 349, in register
where=(sql_table.type == 'ar_foreign')))
ProgrammingError: column a.vat_country does not exist
LINE 1: SELECT "a"."id", "a"."vat_country", "a"."country" FROM "part...
Traceback (most recent call last):
File "/opt/trytond/trytond_dist/trytond/protocols/dispatcher.py", line 201, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/opt/trytond/trytond_dist/trytond/wizard/wizard.py", line 275, in execute
return wizard._execute(state_name)
File "/opt/trytond/trytond_dist/trytond/wizard/wizard.py", line 287, in _execute
view['fields'].keys())
File "/opt/trytond/trytond_dist/trytond/wizard/wizard.py", line 93, in get_defaults
defaults.update(default(fields))
File "/opt/trytond/trytond_dist/trytond/modules/party_ar/party.py", line 744, in default_start
if domicilio.get('tipoDomicilio') == 'FISCAL':
AttributeError: 'list' object has no attribute 'get'
more information regarding:
https://groups.google.com/d/msg/pyafipws/exH4ez5aIj4/iN7KU5ocEQAJ
seems that we need to replace ws_padron_A4 by ws_padron_A5 or padronA10
Since the implementation of WsPadronA5 (issue #14 ) It seems that AFIP is blocking the IP when there are many request from it.
party_ar tries to update the information of the iva_condition of the parties, and when does many request asking for the information of differentes cuits, at same point it brings null information. Perhaps, we could apply some kind of delay on the requests.
Traceback (most recent call last):
File "/opt/trytond/trytond-server/trytond_dist/trytond/ir/cron.py", line 165, in _callback
getattr(Model, cron.function)(*args)
File "/opt/trytond/trytond-server/trytond_dist/trytond/modules/party_ar/party.py", line 383, in import_cron_afip
cls.import_census(args)
File "/opt/trytond/trytond-server/trytond_dist/trytond/model/modelview.py", line 617, in wrapper
return func(cls, *args, **kwargs)
File "/opt/trytond/trytond-server/trytond_dist/trytond/modules/party_ar/party.py", line 374, in import_census
party.set_padron(padron, button_afip=False)
File "/opt/trytond/trytond-server/trytond_dist/trytond/modules/party_ar/party.py", line 334, in set_padron
self.save()
File "/opt/trytond/trytond-server/trytond_dist/trytond/model/descriptors.py", line 31, in newfunc
return self.func(owner, [instance], *args, **kwargs)
File "/opt/trytond/trytond-server/trytond_dist/trytond/model/modelstorage.py", line 1459, in save
(([r], save_values[r]) for r in to_write), ()))
File "/opt/trytond/trytond-server/trytond_dist/trytond/model/modelsql.py", line 934, in write
cls._validate(sub_records, field_names=all_field_names)
File "/opt/trytond/trytond-server/trytond_dist/trytond/model/modelstorage.py", line 1012, in _validate
required_test(getattr(record, field_name), field_name)
File "/opt/trytond/trytond-server/trytond_dist/trytond/model/modelstorage.py", line 987, in required_test
error_args=cls._get_error_args(field_name))
File "/opt/trytond/trytond-server/trytond_dist/trytond/error.py", line 74, in raise_user_error
raise UserError(error)
UserError: ('UserError', (u'El campo \xabNombre\xbb en \xabEntidad\xbb es requerido.', ''))
error AttributeError: module 'trytond.backend' has no attribute 'get' al intentar actualizar modulos instalados account_ar account_invoice_ar bank_ar y party_ar party_ar response AttributeError: module 'trytond.backend' has no attribute 'get' en tryton 5.6 (se trata de un error en la librería o en la intregracion con pyafipsws?)
y en el cliente crashea con el sig: ERROR trytond.protocols.dispatcher <class 'trytond.ir.module.Module'>.activate(*([18], {'client': '683f5a96-2ffc-4630-9661-c3df2de8677e', 'warehouse': None, 'employee': None, 'company': 1, 'company.rec_name': 'Coopevic Ltda', 'language': 'es', 'language_direction': 'ltr', 'groups': [1, 7, 9, 2, 8, 3, 13, 5, 4, 6, 11, 10, 12], '_timestamp': {'ir.module,18': '1597358996.97072'}}), **{}) from [email protected]//tryton_test/
Traceback (most recent call last):
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/protocols/dispatcher.py", line 181, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/model/modelview.py", line 725, in wrapper
return func(cls, records, *args, **kwargs)
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/ir/module.py", line 39, in wrapper
return func(cls, modules)
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/ir/module.py", line 216, in activate
modules_activated.update((m for m in get_parents(module)
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/ir/module.py", line 212, in get_parents
parents.update(get_parents(p))
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/ir/module.py", line 212, in get_parents
parents.update(get_parents(p))
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/ir/module.py", line 212, in get_parents
parents.update(get_parents(p))
[Previous line repeated 900 more times]
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/ir/module.py", line 210, in get_parents
parents = set(p for p in module.parents)
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/model/fields/function.py", line 130, in get
return super().get(inst, cls)
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/model/fields/field.py", line 336, in get
return inst.getattr(self.name)
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/model/modelstorage.py", line 1560, in getattr
read_data = self.read(list(ids), list(ffields.keys()))
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/model/modelsql.py", line 839, in read
getter_results = field.get(ids, cls, field_list, values=result)
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/model/fields/function.py", line 106, in get
return dict((name, call(name)) for name in names)
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/model/fields/function.py", line 106, in
return dict((name, call(name)) for name in names)
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/model/fields/function.py", line 99, in call
return method(records, name)
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/ir/module.py", line 148, in get_parents
parent_names = list(set(d.name for m in modules
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/ir/module.py", line 149, in
for d in m.dependencies))
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/model/fields/field.py", line 336, in get
return inst.getattr(self.name)
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/model/modelstorage.py", line 1560, in getattr
read_data = self.read(list(ids), list(ffields.keys()))
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/model/modelsql.py", line 820, in read
getter_result = field.get(ids, cls, fname, values=result)
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/model/fields/one2many.py", line 138, in get
targets.append(Target.search(clause, order=self.order))
File "/home/usuario/.local/lib/python3.6/site-packages/trytond/model/modelsql.py", line 1317, in search
cursor.execute(*select)
File "/home/usuario/.local/lib/python3.6/site-packages/sql/init.py", line 194, in iter
yield str(self)
File "/home/usuario/.local/lib/python3.6/site-packages/sql/init.py", line 579, in str
columns = ', '.join(map(self._format_column, self.columns))
File "/home/usuario/.local/lib/python3.6/site-packages/sql/init.py", line 500, in _format_column
return '%s AS %s' % (expression, column)
File "/home/usuario/.local/lib/python3.6/site-packages/sql/init.py", line 1365, in str
return 'CAST(%s AS %s)' % (value, self.typename)
File "/home/usuario/.local/lib/python3.6/site-packages/sql/functions.py", line 112, in str
+ ')')
File "/home/usuario/.local/lib/python3.6/site-packages/sql/functions.py", line 74, in _format
return str(value)
File "/home/usuario/.local/lib/python3.6/site-packages/sql/conditionals.py", line 94, in str
+ '(' + ', '.join(map(self._format, self.values)) + ')')
File "/home/usuario/.local/lib/python3.6/site-packages/sql/conditionals.py", line 43, in _format
return str(value)
File "/home/usuario/.local/lib/python3.6/site-packages/sql/init.py", line 1324, in str
alias = self._from.alias
File "/home/usuario/.local/lib/python3.6/site-packages/sql/init.py", line 251, in alias
return AliasManager.get(self)
File "/home/usuario/.local/lib/python3.6/site-packages/sql/init.py", line 156, in get
if getattr(cls.local, 'alias', None) is None:
RecursionError: maximum recursion depth exceeded in comparison
4488 140416439547648 [2020-08-14 20:50:42,673] INFO werkzeug 127.0.0.1 - - [14/Aug/2020 20:50:42] "POST /tryton_test/ HTTP/1.1" 200 -
Sería grandioso que se pueda instalar como los otros módulos de tryton :/
python setup.py install
Ayudaría mucho a los novatos como uno!
Check it out:
https://www.argentina.gob.ar/sites/default/files/tabla-de-cuit-de-extranjeros.pdf
I think the best is to populate the model vat foreign so it will be more easy to the users to add a new foreign party.
En el metodo set_vat_numbe, pasar el campo code por cuit.compact().
https://arthurdejong.org/python-stdnum/doc/1.8/stdnum.ar.cuit.html
Es algo parecido a lo que hacemos en bank_ar con el valor del cbu.
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.