Skip to content
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

[MIG] 11.0: base_business_document_import #42

Merged
merged 35 commits into from
Feb 21, 2018

Conversation

njeudy
Copy link
Collaborator

@njeudy njeudy commented Jan 28, 2018

No description provided.

alexis-via and others added 30 commits January 27, 2018 22:30
…voice dict, cleaner organisation)

Code refactoring: move code in base_business_document_import, factorise code for tax matching (it was duplicated in UBL and ZUGFeRD)
Now support PDF with embedded UBL XML file
Enable unittests on account_invoice_import_ubl
More absolute xpath in account_invoice_import_ubl instead of relative xpath

WARNING: these are big changes, I may have broken a few details
Adapt module account_invoice_import_ubl to use the new base_ubl module
Small fixes
Better generation of address block in UBL (make it coherent with the datamodel of Odoo)
Add generation of several UBL blocks: language, delivery, payment terms, customer party, spplier party
Add parsing of zip in UBL party (will be used in the future for delivery partner match)
Use country code and state code to match partners
UBL: Add delivery terms and line item UBL XML block generation
UBL: add parsing of delivery block
Add unitests in base_business_document_import
Small code enhancements/simplifications
Code cleanup/minor changes
Rename key 'quantity' to 'qty' in all parsing dicts['lines']
Add common methods compare_lines() and post_create_or_update()
Make sure price_unit is always untaxed in UBL XML files
Add support for partner bank matching on invoice update (before, it was only supported on invoice creation)
[FIX] LINT

Use try/except when importing external libs
Remove self.ensure_one() that has nothing to do in an api.model method
Rename __openerp__.py to __manifest__.py and set installable to False
Add match for accounts and journals
Improve match for journals and accounts
Also port all the modules that generate the XML documents: account_invoice_ubl, account_invoice_zugferd, purchase_order_ubl and sale_order_ubl
… module

Fix spelling mistake and other remarks on README by Tarteo
…o v10.0

base_business_document_import: Add support for the creation of res.bank
Add support for insertion of title in error messages
Add method to create SO in sale.order.import accessible via JSON-RPC
@njeudy
Copy link
Collaborator Author

njeudy commented Jan 28, 2018

@alexis-via @hbrunn I don't know what to do for this lint error .. it seems to be ok like this ?

base_business_document_import/models/business_document_import.py:870: [C8107(translation-required), BusinessDocumentImport.post_create_or_update] String parameter on "message_post" requires translation. Use _(('%s %s') % ((msg, parsed_dict['note'])))
count_errors 0

@moylop260
Copy link

@njeudy The lint `C8107(translation-required)' is a beta one (don't affect the travis build result) and have a issue related OCA/pylint-odoo#187

The real lint red is because flake8 lints:

base_business_document_import/models/business_document_import.py:262:16: F821 undefined name 'e'
base_business_document_import/models/business_document_import.py:844:24: F821 undefined name 'e'
base_business_document_import/models/business_document_import.py:846:16: F821 undefined name 'e'
base_business_document_import/tests/test_business_document_import.py:137:16: F821 undefined name 'e'

@njeudy njeudy force-pushed the 11-mig-base_business_document_import branch 3 times, most recently from 9e7703f to 162d69d Compare January 29, 2018 11:53
@coveralls
Copy link

Coverage Status

Coverage remained the same at 53.604% when pulling 162d69dbdc4b66045600cb97872d401a51b7fceb on njeudy:11-mig-base_business_document_import into b13c8e9 on OCA:11.0.

@coveralls
Copy link

coveralls commented Jan 29, 2018

Coverage Status

Coverage remained the same at 53.604% when pulling 0810ed0 on njeudy:11-mig-base_business_document_import into b13c8e9 on OCA:11.0.

@njeudy njeudy changed the title WIP: 11 mig base business document import [MIG] 11.0: base_business_document_import Jan 29, 2018
netloc = urlp.netloc
if not urlp.scheme and not netloc:
netloc = urlp.path
if netloc and netloc.split('.') >= 2:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be:

if netloc and len(netloc.split('.')) >= 2:

otherwise I get this error:

Error:
Odoo Server Error

Traceback (most recent call last):
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/odoo-11.0/odoo/http.py", line 646, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/odoo-11.0/odoo/http.py", line 307, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/odoo-11.0/odoo/tools/pycompat.py", line 87, in reraise
    raise value
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/odoo-11.0/odoo/http.py", line 683, in dispatch
    result = self._call_function(**self.params)
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/odoo-11.0/odoo/http.py", line 339, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/odoo-11.0/odoo/service/model.py", line 97, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/odoo-11.0/odoo/http.py", line 332, in checked_call
    result = self.endpoint(*a, **kw)
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/odoo-11.0/odoo/http.py", line 927, in __call__
    return self.method(*args, **kw)
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/odoo-11.0/odoo/http.py", line 512, in response_wrap
    response = f(*args, **kw)
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/odoo-11.0/addons/web/controllers/main.py", line 934, in call_button
    action = self._call_kw(model, method, args, {})
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/odoo-11.0/addons/web/controllers/main.py", line 922, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/odoo-11.0/odoo/api.py", line 689, in call_kw
    return call_kw_multi(method, model, args, kwargs)
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/odoo-11.0/odoo/api.py", line 680, in call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/oca/account_invoice_import/wizard/account_invoice_import.py", line 401, in import_invoice
    parsed_inv['partner'], parsed_inv['chatter_msg'])
  File "/home/onestein/Pycharm/Gitlab/odoo-11.0/src/oca/base_business_document_import/models/business_document_import.py", line 134, in _match_partner
    if netloc and netloc.split('.') >= 2:
TypeError: unorderable types: list() >= int()

@njeudy njeudy force-pushed the 11-mig-base_business_document_import branch 2 times, most recently from 885a709 to fbeec83 Compare January 31, 2018 17:16
logger.info('Trying to find an embedded XML file inside PDF')
res = {}
try:
fd = StringIO(pdf_file)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need BytesIO here. I get an error otherwise, could you also check?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@astirpe can you past error ? import test file are working ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I remember now...
There is a try that prevents you to see any error.
So just place your debugger breakpoint on that line and notice that it always fails: it always enters the except block, which simply says pass. That's why you don't see any error.

BytesIO seems fixing that behavior.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks. it's done

else:
msg = _('<b>Notes in imported document:</b>')
record.message_post(
'%s %s' % (msg, parsed_dict['note']))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check this pylint:

base_business_document_import/models/business_document_import.py:870: [C8107(translation-required), BusinessDocumentImport.post_create_or_update] String parameter on "message_post" requires translation. Use _(('%s %s') % ((msg, parsed_dict['note'])))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

msg is already translated:

msg = _('Notes in imported document:') so, it's ok for me ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a case for # pylint: ignore=$errorname I think

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's translated. Just making the pylint silent would be fine, as @hbrunn says. Is not a blocking issue anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hbrunn where i should add #pylint line ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 870 should be:

record.message_post(  # pylint: disable=translation-required

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done :)

@@ -0,0 +1,3 @@
base_vat_sanitized https://github.com/OCA/partner-contact.git
account_tax_unece https://github.com/onesteinbv/community-data-files 11_mig_account_tax_unece
product_uom_unece https://github.com/OCA/community-data-files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the modules in the dependencies are merged. You can rewrite the oca_dependencies.txt using the definitive list of repositories.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok done, thanks @astirpe

@njeudy njeudy force-pushed the 11-mig-base_business_document_import branch 5 times, most recently from 53bd9e9 to 36eb65c Compare February 21, 2018 13:10
Copy link
Member

@astirpe astirpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
Only two minor comments, not blocking of course.
For me this module is ok to be merged.

'name': 'Akretion France',
'ref': 'C1242',
'phone': '01.41.98.12.42',
'fax': '01.41.98.12.43',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Fax" field was removed, please remove this line as well.

'phone': '01.41.98.12.42',
'fax': '01.41.98.12.43',
}
The keys 'phone' and 'fax' are used by the module
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please removed the 'fax' also here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you re right !!! done !

@njeudy njeudy force-pushed the 11-mig-base_business_document_import branch from 36eb65c to 0810ed0 Compare February 21, 2018 13:25
@njeudy
Copy link
Collaborator Author

njeudy commented Feb 21, 2018

@moylop260 @hbrunn ready to merge this one ?

@hbrunn hbrunn merged commit 785fe57 into OCA:11.0 Feb 21, 2018
@astirpe
Copy link
Member

astirpe commented Apr 12, 2018

FYI #54

@pedrobaeza pedrobaeza mentioned this pull request Jun 22, 2018
27 tasks
etobella pushed a commit that referenced this pull request Mar 31, 2022
Signed-off-by pedrobaeza
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants