-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
[14.0][IMP] Big simplification, update and cleanup #198
[14.0][IMP] Big simplification, update and cleanup #198
Conversation
Hi @luc-demeyer, |
@victoralmau please check this |
fbf24b6
to
766d016
Compare
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.
First of all thank you very much for trying to simplify the logic and unnecessary fields of these modules (even if the diff is large).
I think I understand the reason for removing the fields in res.company
and adding them now in account.fiscal.position
, would a migration script be necessary to define the corresponding values in all fiscal positions and thus maintain a similar behavior to the current one?
What do you think about this approach @pedrobaeza?
Could you try to separate all these changes in small commits easier to review (I know this is a bit difficult now, but it will help to understand the changes better and also in the future if it is merged)?
if country and country.code == "GB" and self.year >= "2021": | ||
vat = inv.commercial_partner_id.vat | ||
if not vat: | ||
line_notes = [ | ||
_( | ||
"On invoice '%s', the source/destination country " | ||
"is United-Kingdom and the fiscal position is '%s'. " | ||
"Make sure that the fiscal position is right. If " | ||
"the origin/destination is Northern Ireland, please " | ||
"set the VAT number of the partner '%s' in Odoo with " | ||
"its new VAT number starting with 'XI' following Brexit." | ||
) | ||
% ( | ||
inv.name, | ||
inv.fiscal_position_id.display_name, | ||
inv.commercial_partner_id.display_name, | ||
) | ||
] | ||
self._format_line_note(inv_line, notedict, line_notes) | ||
elif not vat.startswith("XI"): | ||
line_notes = [ | ||
_( | ||
"On invoice '%s', the source/destination country " | ||
"is United-Kingdom, the fiscal position is '%s' and " | ||
"the partner's VAT number is '%s'. " | ||
"Make sure that the fiscal position is right. If " | ||
"the origin/destination is Northern Ireland, please " | ||
"update the VAT number of the partner '%s' in Odoo with " | ||
"its new VAT number starting with 'XI' following Brexit." | ||
) | ||
% ( | ||
inv.name, | ||
inv.fiscal_position_id.display_name, | ||
vat, | ||
inv.commercial_partner_id.display_name, | ||
) | ||
] | ||
self._format_line_note(inv_line, notedict, line_notes) |
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.
Can we maintain these warnings with this new approach?
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, we could keep the second warning and restrict it for B2B (vat_required=True on fiscal position). We should drop the first warning (or make it generic for B2B when vat_required=True on the fiscal position.
# adapted accordingly | ||
# Note that, in l10n_fr_intrastat_product and maybe in other localization modules | ||
# region_id is left empty and Odoo writes directly in region_code | ||
region_code = fields.Char() |
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.
Perhaps another option would be to make the compute store=True field to avoid the onchange and be able to overwrite it in other modules.
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.
No, because, in l10n_fr_intrastat_product, I don't use the object "intrastat.region", because I already have another object for that in the french localisation. That's why I want to have the char field region_code.
Why not having both the fields in |
We must welcome simplifications but unfortunately legal reports must also adhere to legal requirments. I agree with some of the proposed changes but imho we should go a lot further. I also think we can go further in simplifying the user experience while keeping at least the current level of legal compliancy (for compliancy we should imho improve the link with the shipments, this is e.g. required in order to correctly handle refunds). It's a very complex legal report and the legal specs are also changing constantly (as we have seen with the brexit, the harmonisation of the transactions codes, the b2b & b2c handling, ... ) and unfortunately not with the same speed in the different EU member countries. I think it's going to be hard (unproductive) to take the right decisions on base module functionality versus localisation modules via a github thread. What about organising a 3 days code sprint with a limited set of people having a good functional functional view on the regulations ? We currently have the french, spanish and belgian localisaiton modules and the generic declaration for use in the other countries. Hence I propose a code sprint with representatives of at least France (Alexis ?), Belgium (myself) and Spain where we define on how to move forward and create the 16.0 intrastat modules. A question specifically for @pedrobaeza : |
in the meanwhile I figured out that our italian colleagues also maintain an intrastat module (cf. https://github.com/OCA/l10n-italy/blob/14.0/l10n_it_intrastat) but this one does not build upon intrastat_product. |
It's not feasible to make inter-repositories checks from a change on the base one, sorry. |
@pedrobaeza having the m2o fields for intrastat.transaction both on account.fiscal.position and res.company as fallback is a possibility. I didn't feel the need for it because I usually have 1 or 2 fiscal position for intrastat, not more. But, if you do B2C and you are above the 10k€/year limit, then I suppose that you end up with 26 intrastat B2C fiscal positions, and that's where it could be an advantage to have the fallback configuration on res.company. |
@luc-demeyer Thanks for your proposal to organise a code sprint on intrastat. But, for me, it illustrates the problem of this generic module: it is very complex and time-consuming to agree on the implementation details of this generic module. And, in all the very important things that we need to work on to improve OCA accounting (bank statement, payment orders, ...), intrastat should not be so high on the list. In other words : if I wanted to participate to an OCA code sprint in the coming months, I would prefer to have it on other topics than intrastat. When I made this PR, I was quite upset about the situation of the intrastat code base, in particular about the over-complexity for Brexit/Northern Ireland and I was evaluating the decision to stop using intrastat_product. So, reading the current comments on the PR, I have the feeling that you agree on my proposal. @luc-demeyer are you really ok about this, in particular the removal of intrastat_base/model/res_partner.py and the removal of the field origin_state_id on product.template ? |
This commit aims at removing the over-complexity of intrastat modules while increasing simplicity/usability for users. - Move default intrastat transaction from res.company to account.fiscal.position to add su pport for B2C (and not just B2B) - improve usability: auto-generate declaration lines and XML export when going from draft to done. Auto-delete declaration lines and XML export when going from done to draft (and add confirmation pop-up). - declaration lines are now readonly. Only computation lines can be created/edited manuall y - add field region_code on computation lines and declaration lines. Remove region_id on declaration lines. This change allows big simplification in some localization modules such as l10n_fr_intrastat_product. - simplify Brexit implementation. Northern Ireland is important, but we can't afford to have so many lines of code and add a field on product.template (origin_state_id) for a territory of 1.9 million inhabitants! This is too costly to maintain and too complex for users. - improve default visibility of fields when reporting_level = 'standard' - add support for weight calculation from uom categories other than units and weight, supposing that the 'weight' field on product.template is the weight per uom of the product - add EU companies from several different countries in demo data with valid VAT numbers
766d016
to
889f9f7
Compare
…ND company Odoo uses, by order of priority: 1) intrastat transaction of the invoice 2) default intrastat transaction of the fiscal position of the invoice 3) default intrastat transaction of the company
@pedrobaeza I implemented your idea in this PR: default intrastat transaction is now both on fiscal position and company.
|
…ning pop-up This is completely new implementation of the messages that are displayed in the warning pop-up: - no double messages - messages are grouped by section and record - nice HTML display insead of raw text
Nice. Please check CI. |
Make tests work
CI is now green |
@@ -55,10 +55,6 @@ def _compute_src_dest_country_id(self): | |||
country = inv.company_id.country_id | |||
inv.src_dest_country_id = country.id | |||
|
|||
@api.model | |||
def _default_src_dest_region_id(self): |
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 hook was done for a reason, so it's not good to remove it.
When manually creating a computation line, auto-set vat from partner_id (partner_id is not a related field any more) Add method _generate_xml()
@@ -4,7 +4,7 @@ | |||
<field name="name">intrastat.region.form</field> | |||
<field name="model">intrastat.region</field> | |||
<field name="arch" type="xml"> | |||
<form string="Intrastat Region"> | |||
<form> |
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.
Don't forget to add sheet.
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
This commit aims at removing the over-complexity of intrastat modules while increasing simplicity/usability for users. Some of you will probably disagree with some of the change in propose in this PR. But I have a strong disagreement with the over-complexity and the over-engineering that was introduced by this Brexit PR #163 For me, this over-complexity has become so expensive in term of software maintenance that, if the changes that I propose here are not accepted in v16, my intrastat v16 module for France will not be based on intrastat_product any more. So far, developping the generic module "intrastat_product" was an investment to try to reach the "ideal" where the biggest part of the code possible is generic. But, when looking at the past experience and where we are today with the codebase and the experience for the user, I think it may not have been the best decision in term of user experience and cost of software maintenance.
There are so many changes that I don't really expect to have it merged in v14 (If you want to merge it in v14, I'll add the migration scripts). But it's a good basis of discussion for v16 with a concrete example. My l10n_fr_intrastat_product module for v14 will be based on this PR (it was broken following the big Brexit changes of PR 163, so I had to fix it anyway).
Here are the main changes: