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

[12.0] Migrate base_business_document_import* #85

Merged
merged 57 commits into from Dec 31, 2019

Conversation

alexis-via
Copy link
Contributor

Migrate base_business_document_import from v11 to v12
Migrate base_business_document_import_phone from v10 to v12
Convert README to new format

@oca-clabot
Copy link

Hey @alexis-via, thank you for your Pull Request.

It looks like some users haven't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement here: http://odoo-community.org/page/cla
Here is a list of the users:

Appreciation of efforts,
OCA CLAbot

@pedrobaeza pedrobaeza added this to the 12.0 milestone Feb 20, 2019
@OCA-git-bot OCA-git-bot mentioned this pull request Feb 20, 2019
18 tasks
'country_id': self.env.ref('base.fr').id,
'type': 'invoice',
})
agrolait = self.env.ref('base.res_partner_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 would prefer to have variable agrolait renamed (eg.: res_partner_2).

@gurneyalex
Copy link
Member

CI is red because of unavailable dependency on base_vat_sanitized

@gurneyalex
Copy link
Member

I added back the oca_dependencies.txt file. @alexis-via rebasing your PR should get a greener build.

alexis-via and others added 24 commits March 4, 2019 14:12
…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
oca-transbot and others added 13 commits March 4, 2019 14:12
Updated by Update PO files to match POT (msgmerge) hook in Weblate.
…import_phone for consistency

Add connector-telephony in oca_dependencies.txt
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
Also port all the modules that generate the XML documents: account_invoice_ubl, account_invoice_zugferd, purchase_order_ubl and sale_order_ubl
When using auto invoice download, the cron is executed by default by admin user, which is above record rules: only handle download config in the company of the user and improve matching by always selecting obj in the same company (or company = False)
… in multi-company environnement

Fix my previous commit on sequence field on invoice import config (caused a crash when creating a new record)
Usability improvements on download config
Migrate base_business_document_import_phone from v10 to v12
Convert readme to the new format
@alexis-via
Copy link
Contributor Author

Thanks Alexandre. I made a rebased, let's see what Travis will say now...

@rubdos rubdos mentioned this pull request Mar 9, 2019
1 task
@astirpe astirpe mentioned this pull request Apr 3, 2019
2 tasks
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.

@alexis-via
Please accept the proposed changes. One test of #101 is failing and the proposed changes fix the error.

The key 'phone' is used by the module
base_phone_business_document_import
"""
rpo = self.env['res.partner']

Choose a reason for hiding this comment

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

Suggested change
rpo = self.env['res.partner']
partner = self.env['res.partner']

Copy link
Member

Choose a reason for hiding this comment

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

For me a partner is an instance of the model 'res.partner' not the class represented by self.env['res.partner']
rpo is better because it's a shorcut. Just my opinion

country = False
if partner_dict.get('country_code'):
countries = self.env['res.country'].search([
('code', '=', partner_dict['country_code'])])

Choose a reason for hiding this comment

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

Why not limit=1, if you only needs one record

if country and partner_dict.get('state_code'):
states = self.env['res.country.state'].search([
('code', '=', partner_dict['state_code']),
('country_id', '=', country.id)])

Choose a reason for hiding this comment

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

limit=1

partners = rpo.search(
domain + [
('parent_id', '=', False),
('sanitized_vat', '=', vat)])

Choose a reason for hiding this comment

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

limit=1

('sanitized_vat', '=', vat)])
if partners:
return partners[0]
else:

Choose a reason for hiding this comment

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

The else sentence is not necessary here, because the if return if its True

domain + [('email', '=ilike', partner_dict['email'])])
if partners:
return partners[0]
else:

Choose a reason for hiding this comment

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

The same here

if not partners and website_domain:
partners = rpo.search(
domain +
[('email', '=ilike', '%@' + website_domain)])

Choose a reason for hiding this comment

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

limit=1

return partners[0]
if partner_dict.get('ref'):
partners = rpo.search(
domain + [('ref', '=', partner_dict['ref'])])

Choose a reason for hiding this comment

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

limit=1

return partners[0]
if partner_dict.get('name'):
partners = rpo.search(
domain + [('name', '=ilike', partner_dict['name'])])

Choose a reason for hiding this comment

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

limit=1

The partner argument is a bit special: it is a fallback in case
shipping_dict['partner'] = {}
"""
rpo = self.env['res.partner']

Choose a reason for hiding this comment

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

Suggested change
rpo = self.env['res.partner']
partner = self.env['res.partner']

@pedrobaeza
Copy link
Member

@alexis-via are you going to finish this?

@alexis-via
Copy link
Contributor Author

@pedrobaeza yes, sure. Now that intrastat is finished for v12, I can come back to edi. Travis is green. I'll have a look at the last remarks in the coming days.

@pedrobaeza
Copy link
Member

Thanks

Improve code for shipping addresse matching
Improve tests
@pedrobaeza
Copy link
Member

Travis is red

@astirpe
Copy link
Member

astirpe commented Jul 31, 2019

Travis errors fixed with a2671fa, this branch should be rebased.

@alexis-via alexis-via merged commit ba8dcb3 into OCA:12.0 Dec 31, 2019
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