-
-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMP] pass nsmap around (or ns object) #131
Comments
example InvNum = root.findtext("/Invoice/cbc:ID", namespaces=nsmap) but we only have @api.model
def _ubl_get_nsmap_namespace(self, doc_name, version='2.1'):
nsmap = {
None: 'urn:oasis:names:specification:ubl:schema:xsd:' + doc_name,
'cac': 'urn:oasis:names:specification:ubl:'
'schema:xsd:CommonAggregateComponents-2',
'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:'
'CommonBasicComponents-2',
}
ns = {
'cac': '{urn:oasis:names:specification:ubl:schema:xsd:'
'CommonAggregateComponents-2}',
'cbc': '{urn:oasis:names:specification:ubl:schema:xsd:'
'CommonBasicComponents-2}',
}
return nsmap, ns |
Challenger will be backwards compatibility. |
guys, just to let you know I'll very soon submit a generic module to work with foreign data models defined by XSD schemas with Odoo. Basically it's based on http://www.davekuhlman.org/generateDS.html Finally I created an Odoo module that makes it easy to inject these mixins into existing Odoo objects like res.partners or account.invoice and specially denormalize or flatten the hierarchies to avoids crazy joins and highly nested forms (while XSD validation typically likes nested tags for a finer grained validation). Alexis always told me UBL is simple enough to be dealt with human written code. May be it is true. Here in Brazil it was not sustainable for the fiscal docs in a open source way. In any case it will work for UBL too, so if you like you may try it soon and see if there is room for improvement in the OCA/edi project too... |
@rvalyi My experience with generateDS is that it can generate unwieldy huge files. How did you work around it? - but maybe that's not even a real problem, actually. Many thanks for letting us know. As soon as you have a peak preview, please shout. I might not be able to use it for the current need though, maybe when migrating the next time... EDIT: How would you do the bindings? Through the mentioned odoo module? Are bindings data or code? |
@blaggacao the XML reader and parser is huge indeed. However when you look at these files in details, you see that except the GeneratedsSuper class, it is may be only twice what you would do by hand if you include the same features. And yes there is that GeneratedsSuper class (that can be shared) but the advantage is your XML parser and reader don't have any extra dependency (unlike say pyXB). As for the Odoo mixins themselves they are as minimalist as they can be. I did a plugin for that, you can see a preview here. It is derivated from the Django plugin but it is not exactly up to date because I'm still doing fine tuning and I am no Mercurial rebase expert https://bitbucket.org/dkuhlman/generateds/pull-requests/51 We will soon push the module to deal with the mixins (not this generator plugin itself) in OCA/l10n_brazil but I guess it may end up interesting lot's of folk dealing with large XSD gramars. I'll let you know when this happen. From a quick look at the UBL XSD's which aren't so small, I tend to think it can be useful here too... |
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
Post processing the document requires
nsmap
for fidelity.You could generate your own, but at the loss of consistency,
Adjust method signature to pass
nsmap
around instead ofns(-prefix)
.This also helps creating ElementMaker from #128
While #128 is cosmetics, the present issue has more weight.
The text was updated successfully, but these errors were encountered: