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

[ADD] l10n_vn_edi: Vietnamese E-Invoicing #160079

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from

Conversation

vin-odoo
Copy link
Contributor

@vin-odoo vin-odoo commented Apr 2, 2024

Add support for E-Invoicing in Vietnam by allowing to connect Odoo with SInvoice by Viettel.

Task id # 3631616


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Contributor

robodoo commented Apr 2, 2024

@vin-odoo vin-odoo force-pushed the 17.0-vn_sinvoice-vin branch 2 times, most recently from 6e24331 to 0825a22 Compare April 2, 2024 04:58
@C3POdoo C3POdoo added the RD research & development, internal work label Apr 2, 2024
@vin-odoo vin-odoo force-pushed the 17.0-vn_sinvoice-vin branch 6 times, most recently from 2c05545 to c419704 Compare April 10, 2024 04:06
@vin-odoo vin-odoo force-pushed the 17.0-vn_sinvoice-vin branch 4 times, most recently from 87be19f to dbe0d15 Compare April 15, 2024 04:22
@vin-odoo vin-odoo force-pushed the 17.0-vn_sinvoice-vin branch 3 times, most recently from adfca8a to fcd6d58 Compare April 23, 2024 03:22
@vin-odoo vin-odoo marked this pull request as ready for review April 26, 2024 08:47
@vin-odoo vin-odoo force-pushed the 17.0-vn_sinvoice-vin branch 8 times, most recently from 6178d53 to 0e7e521 Compare April 29, 2024 08:20
@vin-odoo vin-odoo requested review from a team and hupo-odoo and removed request for a team April 29, 2024 08:20
Copy link
Contributor

@hupo-odoo hupo-odoo left a comment

Choose a reason for hiding this comment

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

The work you have done is very clean and I can't find much to say 😄 Here are a few comments/questions I have so far, I'll keep reviewing next week (went through some of the flows but not all of them yet).
Also, I discussed with Benj and I would like to attend the small meeting you'll have with him for the testing, just to make sure I didn't forget anything. Of course I'll do that if you agree. He told me he would prefer doing it post-freeze as this task is in 17.0.

addons/l10n_vn_edi/__manifest__.py Show resolved Hide resolved
addons/l10n_vn_edi/models/account_move.py Outdated Show resolved Hide resolved
addons/l10n_vn_edi/views/sinvoice_views.xml Outdated Show resolved Hide resolved
addons/l10n_vn_edi/models/account_move.py Outdated Show resolved Hide resolved
addons/l10n_vn_edi/views/account_move_views.xml Outdated Show resolved Hide resolved
Copy link
Contributor

@william-andre william-andre left a comment

Choose a reason for hiding this comment

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

I'm far from done reviewing, but since I had answers for Hugo's review, and I can't post a message while a review is started...
Here you go!

@@ -8,7 +8,7 @@
<field name="country_id" ref="base.vn"/>
<field name="state_id" ref="base.state_vn_VN-06"/>
<field name="zip">76463</field>
<field name="phone">+84 91 234 56 78</field>
<field name="phone">084 91 234 56 78</field>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the change?

Suggested change
<field name="phone">084 91 234 56 78</field>
<field name="phone">0084 91 234 56 78</field>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the EDI does not support + and it would be better if our demo data work out of the box for it when possible.
Maybe a better solution would be to manage the + in the edi code, not quite sure of that.

"description": """
Vietnam - E-invoicing
=====================
Using SInvoice by Viettel
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the module name contain viettel since there are other providers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could, I checked and saw that for other countries we didn't add this information in the name.
That's why I added it in the summary (so that searches are easier).

If you ask to add it, there, I'm ok with that.

addons/l10n_vn_edi/models/res_config_settings.py Outdated Show resolved Hide resolved
addons/l10n_vn_edi/models/sinvoice.py Outdated Show resolved Hide resolved
addons/l10n_vn_edi/models/sinvoice.py Outdated Show resolved Hide resolved
@@ -169,3 +169,8 @@ def refund_moves(self):

def modify_moves(self):
return self.reverse_moves(is_modify=True)

def _modify_move_default_values(self, origin_move):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't this be done through _copy_data_extend_business_fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't know of it, but it looks like it's only for AML and not the moves themselves (which does not seem to have a similar feature)

addons/l10n_vn_edi/models/account_move.py Outdated Show resolved Hide resolved
addons/l10n_vn_edi/models/account_move.py Outdated Show resolved Hide resolved
addons/l10n_vn_edi/__manifest__.py Show resolved Hide resolved
@vin-odoo
Copy link
Contributor Author

@hupo-odoo For the testing with Benj later, of course, feel free to join if needed 😄
I'm fine with doing that post freeze too.

I'll push the changes based on the feedback from you and William when I get some time

Copy link
Contributor

@hupo-odoo hupo-odoo left a comment

Choose a reason for hiding this comment

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

Here are some other comments 😃

addons/l10n_vn_edi/models/account_move.py Outdated Show resolved Hide resolved
addons/l10n_vn_edi/models/account_move.py Outdated Show resolved Hide resolved
addons/l10n_vn_edi/models/account_move.py Outdated Show resolved Hide resolved
Comment on lines 213 to 222
files_data = self._l10n_vn_edi_get_file_data('ZIP')

# Sometimes the documents are not available right away. This is quite rare, but I saw it happen a few times.
# To handle that we will try up to three time to fetch the document => The impact should be negligible.
threshold = 1
while not files_data['fileToBytes'] and threshold < 3:
time.sleep(0.125 * threshold)
files_data = self._l10n_vn_edi_get_file_data('ZIP')
threshold += 1

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure that if the documents are not yet available, the file data will simply not contains the values ? I tried several times, and in some cases, I got the issue "Invoice not found", but as it was an error message, it then raises the error in the _l10n_vn_edi_get_file_data function. I'm wondering if this is the issue that corresponds to the "documents not available" you're trying to solve, or maybe I got another error for unknown reason. Because then in my case, as the error is raised, it does not continue in the while loop, and it is directly raised.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's how it was in my case. the "Invoice not found" is most likely a separate error.
Are you able to reproduce it so that I can check?

addons/l10n_vn_edi/models/account_move.py Outdated Show resolved Hide resolved
errors.append(_('Sinvoice credentials are missing on company %s.', company.display_name))
if not company.vat:
errors.append(_('VAT number is missing on company %s.', company.display_name))
if company.phone and not company.phone.replace(' ', '').isdecimal():
Copy link
Contributor

Choose a reason for hiding this comment

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

checking if there are only digits might be a bit too restrictive. For example, if I try to set a US phone number (starting by 001), it is automatically formatted with +1, and will therefore raise an error when sending an invoice to this customer.

Copy link
Contributor Author

@vin-odoo vin-odoo May 22, 2024

Choose a reason for hiding this comment

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

Yes, it's annoying =/
The API Only supports digits. The only solution would be to automatically replace "+" by "00" in the code if it's there?

I did a simple phone number cleaning method and used that but not 100% sure it's ideal.

addons/l10n_vn_edi/models/account_move.py Outdated Show resolved Hide resolved
addons/l10n_vn_edi/models/account_move.py Outdated Show resolved Hide resolved
addons/l10n_vn_edi/models/account_move.py Outdated Show resolved Hide resolved
addons/l10n_vn_edi/views/account_move_views.xml Outdated Show resolved Hide resolved
@vin-odoo vin-odoo force-pushed the 17.0-vn_sinvoice-vin branch 2 times, most recently from 8ab740f to fbf1677 Compare May 22, 2024 03:33
Add support for E-Invoicing in Vietnam by allowing
to connect Odoo with SInvoice by Viettel.

Task id # 3631616
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants