-
-
Notifications
You must be signed in to change notification settings - Fork 162
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
[13.0][MIG] ebill_paynet #551
Conversation
This is removed because there is dedicated addon `server_env_ebill_payneta` to manage that
Before one job was polling for shipment and downloading/acknowledging them. This could lead to incoherent state between Odoo and the distant server. Now one job polls for shipment and creates one job for each new shipment to be downloaded and parsed. Also add improvement in the UI.
This depends on some other modules, maybe add that in
|
ebill_paynet/components/api.py
Outdated
"""PayNet DWS web services.""" | ||
|
||
def __init__(self, url, test_service): | ||
settings = Settings(xml_huge_tree=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use directly zeep.Settings
, this avoid to read the imports statements to know what we are talking about as it's not an usual dependency in the Odoo ecosystem. But it's a matter of taste I suppose :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes clearer, but with an import zeep
are we not importing more than necessary and it would be bad performance wise ? (real question that I don't know the answer)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TDu good question to ask.
AFAICT import
does 2 things, it imports the modules and submodules and fill the namespace.
The best practices says that from module import *
is discouraged. Because it fills the namespace with every part of module
.
When using the from
you target a submodule or code of the main module in any case you will also load the module itself.
If you test the following in your python shell to load :
>>> import sys
>>> sys.modules['zeep']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'zeep'
>>> from zeep import Settings
>>> Settings
<class 'zeep.settings.Settings'>
>>> sys.modules['zeep']
<module 'zeep' from '/home/yvaucher/.local/lib/python3.6/site-packages/zeep/__init__.py'>
>>> sys.modules['zeep'].Settings
<class 'zeep.settings.Settings'>
>>> sys.modules['zeep'].Client
<class 'zeep.client.Client'>
>>> Client
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Client' is not defined
As you can see the zeep
module is fully loaded but the namespace doesn't contains everything.
But what is a submodule?
https://docs.python.org/3/reference/import.html#submodules
A submodule is a sub file or directory that is not mentionned in the __init__.py
It's different from code that is part of the main module which must appear in the __init__.py
file.
To deep in details, you can't import too much things unless you ask for a submodule you don't use.
Consider the following module with 2 submodules and some initialization code:
module
├── initialization.py
├── __init__.py
├── sub1.py
└── sub2.py
The content of module/__init__.py
is
from . import initialization
print('import whole module')
Now let's test it:
>>> import module
load initialization
import whole module
>>> module.initialization
<module 'module.initialization' from '/tmp/module/initialization.py'>
>>> module.sub1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'module' has no attribute 'sub1'
Only what is mentionned as from . import ....
(in module/__init__.py
file) is loaded with the module.
>>> from module import initialization
load initialization
import whole module
>>> from module import sub1
load sub1
>>> from module import sub1, sub2
load sub2
Same here, only what is mention as from . import ....
(in module/__init__.py
file) is loaded with the module.
You also see that it reminds what has been previously loaded.
>>> from module import sub1
load initialization
import whole module
load sub1
When importing sub1
the whole module is loaded anyway. But not other sub packages.
>>> from module import *
load initialization
import whole module
>>> initialization
<module 'module.initialization' from '/tmp/module/initialization.py'>
>>> sub1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sub1' is not defined
You might have expected as I did to see an import of sub1 and sub2 but it's not the case, which means that this is discouraged only due to the namespace filling.
Additional note: If you do want to load a subpackage which has a too generic name you could also define an alias on import using
from module import subpackage as msub
This can save you from namespace conflicts.
In conclusion, the proposal of @sebalix is perfectly fine and has not impact other than having one different entry in the name space.
Some references:
https://docs.python.org/3/reference/import.html
https://docs.python.org/3/library/functions.html#__import__
https://stackoverflow.com/questions/12229580/python-importing-a-sub-package-or-sub-module
6f1ccb4
to
9eea61b
Compare
Fix the selection of the bank account of the sale order when paynet transmit method is choosen. Fix the get_active contract that has been moved to base_ebill_payment_contract. Add some fixes proposed by @sebalix.
Some improvements and fixes on invoice message generation : * Fix the payment reference (it was using the old field pre v13) * Allow to have a 2nd line in the biller name node, it uses the company_name_suffix_1 on the company partner for it. * Change the customer reference for the purchase linked to the invoice. * Improve or so I hope the account number if it is a postal account the specific account number is used otherwise we use the bic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small pre-review about terminology.
Please prefer eBill
and e-billing
Implement the QR invoice functionality from SIX specifications. Add on the ebill contract the choice of payment ESR or QR, so it can be specific for each customer. The XML payload has been updated. And the PDF data included improved, so the correct PDF is generated depending of the type of payment.
Add the price and tax node for each line item. Improve the reference on the sale order. Add sale as a dependency and improve the tests by generating the invoice from a sale order.
Fix naming of eBill Improve import statement of zeep
The specifcation accepts only one tax node by line.
The `l10n_ch_postal` field is used for bank account not belonging to the company (like suppliers). The `l10n_ch_isr_subscription_chf` field is the one used for bank account belonging to the company.
The actual invoice and the payment (ESR, QR) reports are not generated together in one PDF so up to know only the page with the payment was sent to Paynet. Now both report are merge and sent to the system.
ebill_paynet/__manifest__.py
Outdated
"account_invoice_export", | ||
"base_ebill_payment_contract", | ||
"l10n_ch_base_bank", | ||
"l10n_ch_qr", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module has been renamed l10n_ch_qriban
Having this field stored will create problems for implementation that uses different stacks (integration/production) And it is not required
Fix some line with a limited length of 35 char. Round some decimal.
Use the partner_shipping_id information for the DELIVERY-PARTY node. Also for all name nodes concerning a res.partner record, add a Line node with the commercial company name if it is different to the partner name.
When downloading a shipment if a fault occurs on the communication with the DWS. The module was trying to parse a content set to None. So the exception must be raised and the information on the error will be available in the job result. Comment answered ;) and removed.
Remove invoice line with a display_type value. The filtering can be overriden, if needed. Handle properly the invoice line not linked to a product. Fix some falsy values.
Reading the specs it seemed to be the other way around. But it has been confirmed by someone at SIX. That the reference for linked sale order must be the customer order reference.
Use the currency of the invoice to generated the message instead of fixing it to CHF. Fix the length of a name
The payment term node in the Paynet message allows to add a discount information in case of payment until a certain date. As this feature does not exist in the standard implementation of Odoo, this is extracted into another module, to give the option to use different implementation for it. See `ebill_paynet_account_financial_discount` for one of them.
This module implements the discount information in the payment terms node of the Paynet message. In regards to the module `account_financial_discount`. When the discount information is present in the payment terms of an invoice, they will automatically be included in the payment term of the Paynet message.
This fixes an issue when downloading a shipment from the DWS, while using a production account.
The module l10n_ch_qr has been renamed to l10n_ch_qriban. For this to work with an updated Odoo src the following PR is required: * odoo/odoo#57710
I open a new PR #585 see why in the description. |
This is based on #499 for 12.0 that has not been merged