Merge lp:~renatonlima/openerp-fiscal-rules/fiscal-classification into lp:openerp-fiscal-rules

Proposed by Renato Lima - http://www.akretion.com
Status: Merged
Merged at revision: 57
Proposed branch: lp:~renatonlima/openerp-fiscal-rules/fiscal-classification
Merge into: lp:openerp-fiscal-rules
Diff against target: 419 lines (+135/-123)
4 files modified
account_product_fiscal_classification/account_product_fiscal_classification.py (+124/-105)
account_product_fiscal_classification/account_product_fiscal_classification_view.xml (+4/-9)
account_product_fiscal_classification/product.py (+6/-8)
account_product_fiscal_classification/product_view.xml (+1/-1)
To merge this branch: bzr merge lp:~renatonlima/openerp-fiscal-rules/fiscal-classification
Reviewer Review Type Date Requested Status
Nhomar - Vauxoo Abstain
Review via email: mp+143393@code.launchpad.net

Description of the change

Changes necessary to adapt views and objects in account_product_fical_classification module for OpenERP v7

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Why is it already merged without any approval?

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi renato,

Thanks for your contribs, but here I completely agree with Guewen, why is this MP merged without any approval.

@Raphaël : We try to put in place some community rules and I know you didn't had time to jump into yet, but please follow them as everyone.

Regards,

Joël

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Hello Joël and Geween,

well basically, we share Alexis de Lattre's opinion about this: basically, we think that the original module authors should be able to just commit, especially when porting on a new OpenERP version which is the case here. Indeed, there is no risk we break anybody stable installation here.

I'm all for code review when third parties are hacking some module that are claimed to be somewhat stable and thank you for that, but for prototyping new things or for porting to whole new release, we cannot always afford to wait for reviews...

That being said, if you have comments about the code, feel free to share them, we can always take them in consideration afterwards. Again, the thing is that we should be able to shape the code quickly, according to what our business model allows.

What do you think?

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Raphaël,

Well, the OpenERP community is actually taking responsability for the modules in these projects now and if module 'initiators' are allowed to commit unreviewed branches to these modules that can undermine this idea.

I must admit I had to get used to it myself but now I find it incredibly rich to have other people validating my changes even to 'my own' modules and sometimes getting valuable comments on them. So would you please reconsider?

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hi Raphaël,

Stefan said very well what I was going to say. Just want to add more arguments.

We now have to think and act as a community.
In this role, we have to share the knowledge and responsibilities and
increase the overall quality of our work, as professionally as we are.

1. Community. If authors are allowed to bypass the reviews, I would see the
reviews as a means to 'protect' our modules rather than to increase their
quality and to share knowledge.
Think about this, partners would end up by reviewing only their 'own' modules (if they do).
A lot of my (and other involved reviewers) time is invested on those
reviews. If it doesn't end up with good results and with the born
of a strong community, if the quality of the modules is hazardous, I think I can stop immediately.
It's all or nothing in that concern.
That would be exactly the same situation than before the organization of the community, except
that 'extra-addons' would be split in many branches.
I would not call that a community, but a... share of branches.

2. Authoring. The more the community will be active and efficient, the less
the notion of author will be clear.

3. Fair. Not every partners have the chance to have a community reviewer in
their team.

And yes, you'll need to change your habits, as much as us and the others
ones which have started this adventure. But I'm intimately convinced that if
everybody play by the rules, it will be worth the pain.

By the way, nobody want to push prototypes in production, isn't it?

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :
Download full text (3.6 KiB)

Dear Guewen and Stefan,

really I like the community review system and I promise we will submit ourselves to it the more possible. And as you can remember we are the one who spent an absurd amount of time to build the branch extraction scripts that just made the modularization possible...
Now really I think that there should have some exceptions and if you think about it, you'll see even you aren't doing any different.

So first of all Guewen, I don't want to sound harsh, but are you doing any different when you claim to rewrite the Magentoerpconnect project in v7? I'm already working on refactoring the lower level dependencies of it too... Where are these nice code review on your early prototypes? How is that different from the refactor we do in our localization?

Now about the fiscal_classification module: it happens it's a module we built for the Brazilian localization but with the hope it could be useful to other countries and this is the reason it's not built in our localization branch. But to day we are unaware of any thord party using it unfortunately... Still we promise we will do demo videos to explain the module better to get more chances to increase its adoption.

Now our business reality is that while OpenERP SA is selling partnerships to competitors leeching at our code and project image without never contributing a single line of code, just Renato Lima and me are carrying around over 15 000 lines/ 21 modules of localization alone. As you can see: it's a very tough reality that you at CampToCamp would be far from assuming when you want to raise 150k euros just to refactor the Magento connector for v7... So I mean, almost nobody is doing what we do in the conditions we do it and unfortunately it means we have to do it the way it can work for us. And the way it can work for us isn't having to wait for people who never used that code to review every little commit we do in the version; unfortunately.

So depending on your company size, location, market, maturity, realities are VERY different. You could think that only CampToCamp reality is valid. Well I would say that NONE of the larger/more comfortable companies did a tenth of what we did for our localization (or even for the Magento connector until quite recently BTW), so I think this is a clear sign that every business reality is valid and not adapting to these micro scales realities would be a terrible loss for the OpenERP eco-system.

By the way, that code as already been deployed in production in a 400 employees companies last month, so it isn't too experimental either (now the former version was utterly borken for such usage).

So again, I think module authors should be allow to opt'in for review or not if they are refactoring for new OpenERP versions. If that is not possible, well, what would happen is that we would simply move out our module from that reviewed branch (that we had started BTW) and used an unreviewed branch as the main branch. I don't think such an extremity is a good idea at all.

Instead what I think is that it's better to maximize code review but without being fanatic about it. That is: everytime you touch a third party module, you submit yourself to the re...

Read more...

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :
Download full text (7.6 KiB)

Dear Raphaël,

I cannot understand your comments here, I'm really sorry. I cannot admit you're speaking about us this way without saying a word. We're talking about the rules that community agree to follow, not quality of your code nor the fact that you're the author, either not that you're code is stable or not. Don't mixed up everything please.

First of all, we're not talking about Akretion's investment in the OpenERP's world, in term of contributions, effort, time, and more. We both know how much we invest here ! That's why we, Camptocamp and Akretion, work hands-in-hands on various topics, with friendship, peace and at the end a win-win situation.

Then, we know you're making all the effort on Brazilian localization, we know that's hard work. Now, do not talk about what you don't know. Do not says "it's a very tough reality that you at Campcocamp would be far from assuming when you want to raise 150k euros just to refactor the Magento connector for v7...". We also assume the devs of thousands lines of code before you even had a look on OpenERP ! All this work was done without one $ from anybody else but Camptocamp. Most of those devs are now part of the core now-days, everybody benefit from it and that's the fantastic Open Source world.

Regarding the connector devs, could I remind you that we already make workshops, talks, specifications and all the rest, sharing everything with Sebastien Beau from your team months before publishing something !? As far as I remember, we now share specs and how we though to build the new generation with the whole community. We already plan to make a code sprint with you all. How the hell can you just ask Guewen where is his code !? Do you really think we won't have the community to review it ? It doesn't seems to be in our habits if you just look at the merge proposal review list.... Without asking a penny, Camptocamp make most of the reviews , and from far !

Finally, regarding the funding on the connector, we though it'll be fare to ask others to contribute on it as it's not always at Akretion, Camptocamp or some core contributors to fund everything. We already, as you've done, put a lot of money here. It seems fair to ask for some other beneficiary to invest a bit. And your team agree on that (or at least Sebastien did).

I don't want to sound harsh, but do not push the button to far away here, this is something I do not like at all. I can understand you're a bit angry regarding Stefan and Guewen answer on you merge. But that's the rules that everybody agree to respect.

You don't want those constraints (that I more see like a benefit), well, put your module in your own branch as you mentioned. No big deal for us if you feel more comfortable with that. But in the community branch, rules must be followed without exceptions. If you do need a quick review, just write to the reviewer mailing, I'm sure somebody will review it in the same day. Moreover, most of the review are made in 2-3 days, we're not at OpenERP ;) and it'll be even faster if you jump in :) ! If you want to continue the debate or suggest other rules please, post your suggestions on the reviewer mailing list (openerp-community-reviewer@l...

Read more...

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :
Download full text (6.0 KiB)

Dear Joel,

I know very well about CampToCamp efforts from the beginning and never questioned that. The thing is you'are now up for a level of bureaucracy we cannot afford from where we are, just not for everything.

Yes you started at a rough time, may be as rough as it is for us to start in Brazil or even harder. Now, your work methodologies certainly adapted to the changes in the situation that is different now than what it was at the cowboy time. But hey, we are still at the cowboy time here ;-) and my goal wasn't to rant about it, but instead to point how the market is being badly addressed making all of us loosing precious time.
In the same line, when we will have a more mature localization and more air to breath, our goal is certainly to conform to better coding methodology standards (that we certainly know from our past lifes in jobs that pay the bill).

About theses modules being community based or not and about the rules standing over them. I should say I was a bit busy after the creation of the branches extraction scripts so couldn't express myself further. But basically I agree with what Alexis de Lattre said about it, which is more or less what I stated again. Or in other words, no I don't agree that things should always get through the bureaucracy of reviews, specially for things that are still in prototype forms like these modules.

I think the eco-system is very large. There is no point in wanting that some people would be able to review everything of it and specially I think expecting it would be counter-productive for everybody. Of course anyone is free to give his opinion about anybody's code and of course we try to submit ourselves to reviews, but I don't think being systematic about this scales.

You seem to see the world a bit binary: review or not review at all. Well if so we may move again these modules under other groups. Notice that while we created these branch it's not me who putted them under these core-accounting group, so saying I agreed with all the rules is a bit fast...

Really my intention is not to polemic, but I have a different vision: I think some projects like this one have leaders despite receiving appreciated third parties contributions. But in these cases, I think these third parties contributions should submit themselves to review, but not necessarily impose the reverse or we kill productivity. I mean imagine, caricaturing a bit, it would be like asking the kernel developers to review every commit of every program that run on Linux, just because it runs on Linux. Of course it's a caricature, but I think the reason it wouldn't fundamentally scale are the same.

Again, I really consider reviews as good practices, and think they could be mandatory for the stable branches. I just don't think it's productive to make them mandatory in such situations.

If you want groups where reviews are mandatory. We could even do it, but in that case, I think we would need several groups and review only inside a group and not a single golden group. But again, not even sure it would be productive for such a case given nobody else is using or maintaining that code.

About the connector: sorry but I think the situation is...

Read more...

Revision history for this message
Nhomar - Vauxoo (nhomar) wrote :

Hello Raph.

IMHO, rule is rule, you follow the rule or died try it.

It means,

2 options here:

Option A:

1.- Build your own copy of the community branch -
2.- Propose the merge.
3.- Read with open mind.
4.- Mantain Updated your specific local branch until the work is merged.
5.- Fix corrections.
....
6.- It will be merged.
7.- Correct the :parent: in your local branch.

Option B:

1.- Not propose the module for a community branch.
2.- Use it and mantain it.
3.- When you think it will pass and you have the time, make the MP.
4.- Everybody happy.

Raph, imagine for one second, you must hire 20 Q&A, and pay for the job to ensure your customer will have the BEST software in the world, how much it will cost in terms of money to your customer??

Dude!, your customer must pay the job, or you pay for it, but here the discusion is not about Who pay for it or not, and Who win money or not, and Who Find a profitable or not profitable way to do them own Job or not.

Please, exactly in the same way you feel when somebody else that take your job and makes money without giving you back nothing, we feel when somebody else because <whatever reason here> wants to bypass Simple Rules.

I promise i will post a blogpost giving a way about how you must manage opensource developments in OpenERP Community ecosystems to explain by myself better, ok my conclusion,

Respect the rules, >>>1st community's alert to you,
<joke> You are not Chuck Norris, Openerp's community is Chuck Norris </joke> :-)

http://college.oxy.edu/admissionblog/files/2011/10/Thumbs-UP.jpg

review: Abstain
Revision history for this message
Nhomar - Vauxoo (nhomar) wrote :
Download full text (23.3 KiB)

About the code:

Just making:

pep8 . in the folder downloaded:

./account_fiscal_position_rule_sale/__openerp__.py:28:80: E501 line too long (87 > 79 characters)
./account_fiscal_position_rule_sale/__openerp__.py:32:80: E501 line too long (141 > 79 characters)
./account_fiscal_position_rule_sale/__openerp__.py:37:17: E122 continuation line missing indentation or outdented
./account_fiscal_position_rule_sale/sale.py:48:24: E121 continuation line indentation is not a multiple of four
./account_fiscal_position_rule_sale/sale.py:53:24: E123 closing bracket does not match indentation of opening bracket's line
./account_fiscal_position_rule_sale/sale.py:70:24: E121 continuation line indentation is not a multiple of four
./account_fiscal_position_rule_sale/sale.py:75:24: E123 closing bracket does not match indentation of opening bracket's line
./account_fiscal_position_rule_sale/sale.py:93:24: E121 continuation line indentation is not a multiple of four
./account_fiscal_position_rule_sale/sale.py:98:24: E123 closing bracket does not match indentation of opening bracket's line
./account_product_fiscal_classification/__openerp__.py:34:9: E126 continuation line over-indented for hanging indent
./account_product_fiscal_classification/__openerp__.py:35:9: E122 continuation line missing indentation or outdented
./account_product_fiscal_classification/__openerp__.py:24:11: E203 whitespace before ':'
./account_product_fiscal_classification/__openerp__.py:25:14: E203 whitespace before ':'
./account_product_fiscal_classification/__openerp__.py:27:13: E203 whitespace before ':'
./account_product_fiscal_classification/account_product_fiscal_classification.py:25:1: E302 expected 2 blank lines, found 1
./account_product_fiscal_classification/account_product_fiscal_classification.py:29:17: E126 continuation line over-indented for hanging indent
./account_product_fiscal_classification/account_product_fiscal_classification.py:32:18: E121 continuation line indentation is not a multiple of four
./account_product_fiscal_classification/account_product_fiscal_classification.py:33:18: E121 continuation line indentation is not a multiple of four
./account_product_fiscal_classification/account_product_fiscal_classification.py:44:1: W293 blank line contains whitespace
./account_product_fiscal_classification/account_product_fiscal_classification.py:48:23: E701 multiple statements on one line (colon)
./account_product_fiscal_classification/account_product_fiscal_classification.py:57:80: E501 line too long (126 > 79 characters)
./account_product_fiscal_classification/account_product_fiscal_classification.py:71:80: E501 line too long (86 > 79 characters)
./account_product_fiscal_classification/account_product_fiscal_classification.py:72:21: E128 continuation line under-indented for visual indent
./account_product_fiscal_classification/account_product_fiscal_classification.py:73:1: W293 blank line contains whitespace
./account_product_fiscal_classification/account_product_fiscal_classification.py:75:80: E501 line too long (136 > 79 characters)
./account_product_fiscal_classification/account_product_fiscal_classification.py:76:80: E501 line too long (153 > 79 characters)
./accoun...

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

+1 for Nhomar point of view... Rules are rules. They are not mine, but community ones. If you do not agree with them, ask to change them on the mailling. Since there, you follow them or make your own branch.

OpenERP-Magento connector that we're building will be publish AND REVIEW as soon as we'll have something that make sense.

Cheers,

Joël

--

Joël Grand-Guillaume
Division Manager
Business Solutions

Camptocamp SA
PSE A, CH-1015 Lausanne
http://openerp.camptocamp.com/

Phone: +41 21 619 10 28
Office: +41 21 619 10 10
Fax: +41 21 619 10 00
Email: <email address hidden>

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Would it be a solution if the community reviewers retreated from this project and maybe a (hopefully) small number of other projects that are in this stage of development? We could put up a note on the main page of the other projects declaring that they adhere to the community review policy published in the OpenERP documentation. At least in that case the responsability would be clear.

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :
Download full text (4.1 KiB)

@Nhomar with all the respect, if you want to play the PEP8 hero, you would do a more productive job running them against the core of OpenERP... we are absolutely aware of the PEP8 issues in that branch, but again we had other priorities in the past than building PEP8 compliant code over a sandy OpenERP basis and a muddy business model. That being said, if you look at the evolution of our code, you'll see that the code we migrate is being improved a lot regarding to PEP8. Now less than half of the modules in that branch have been migrated to v7 so again, priorities are certainly others.

@Stefan, I think you are hitting the spot! This branch is actually a good example: this is a group of modules we at least in Brazil tend to use together because our localization depends on all of them (though as I said they may not be localization specific and that's why we moved them out).

Now, among these modules of that branch, some modules have been used by contributing third parties in other contexts such as CampToCamp, SavoirFaireLinux in Canada and the French part of Akretion, in order to address taxes in multi-countries situations (with e-commerce mostly), which is the same problematic as managing taxes in federations of countries with fiscal sovereignty such as what we have in Brazil.
It means, that we should ideally be careful with the modules used by these good willing third parties, while we mostly need to be agile to address our localization needs.

Does it mean we should split these modules into more branches and face an even harder chaos of possibly incompatible branches when it comes down to installing our localization? To give you a better picture, I would say that even with theses grouped branches, around half of the companies being hired as official "partners" in Brazil are unable to install/update the localization. I mean, going more branching chaos is certainly on the table, but at some point it sucks because the guys supposed to represent us, would then have expectations even farther from the hard reality and that certainly ends up...

So what do we do? To sum up we see that with these branches we are largely solving the "modularization" problem the monolithic extra-addons had. Now, Joel and others want to also fix the "quality" part of the community module. I would say that it's two different issues and the quality part is even harder to address as long as we cannot have one module=one branch + a decent way of installing and testing the whole against the explosion of possible combinations (a problem largely fixed in the software industry minus in OpenERP who always try to re-invent the wheel, now with the apps that is in clear business conflict with these quality requirements).

At some point, what I tried to defend is a flexible system where some modules in stables branches could get stronger commit rules, while these rules could be relaxed in some other cases like this one. We can very well say "the rule is the rule and that's it". But my fear is that if we follow that, we will fragment the ecosystem of modules in much more unmanageable branches for the mortals (or make the community unattractive in other words) and have only a very...

Read more...

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Dear Raphaël,

Why saying that having a review on all community project/branches will be less flexible and/or lead to more chaotic branches !?

Before claiming that, will you just please make a MP and wait for the review once ? I mean, you don't even "play" the game once before saying this won't work for tons of reasons... I perfectly understand your fear my friends, trust me. I know you don't want to rely on others in some situations... I had the same at the beginning. But that's part of the game to build strong module and community. If you really want to be hell quick once, well make an exceptions on your side by using your own branch till the MP is approved...

As MP are reviewed within 1-3 days currently I think it's not blocking anybody in his work. We never really slow down each other this way... If you join the review, we'll be even more quick. As I said, it's not like with OpenERP MP review here, you don't wait months !

What I suggest is that you try working with the rules in place, if it doesn't fit your needs, then well, launch the debate on the community reviewer mailling list. It seems fair to me, what do you think ?

Have a nice week-end,

Joël

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

P.S. After a quick check, all reviews are made in less than a day on community branch currently. Just look in the MP mailing.. I mean, it's really working well and fast, give the current rules a try (and a chance :) !

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

@Joël,

all right, let's say we will try it this way in the future and if it proves to be too bureaucratic, move to another group.

By the way, even if we didn't pass through the official merge proposal ceremony, Renato and me peered on that (yes at 4 AM during a go live last month on the v6.1 branch; that's the reason we cannot afford more bureaucracy) so it's not like uncertain commits in the wild. That's isn't fundamentally different than 2 C2C developers approving each others...

As for the reasons I didn't play the review game yet, it's certainly boils down to the fact that already investing on the branch extraction scripts was a huge investment for a light structure like us and as I said, migrating 15 000 lines of maturing locatization code to version 7.0 with only two people made us busy enough for not having the luxury to touch too much non localization related code these last months. I would happily peer with others for our localization. The issue is almost nobody here is making such serious investment on the localization, so we end up peering with ourselves so far. This situation is certainly related to the way OpenERP SA addresses this market that's why no matter how important the code is I never miss an occasion to give my opinion about the business model part of the project. At least we manage to peer for a few lower level modules we share with other localizations such as the Spanish one.

Also as we respect the modules used in productions by others, you'll notice that we didn't make the offence of committing these things wildly into the 6.1 "stable" branch but rather maintained our own branch here instead https://code.launchpad.net/~akretion-team/openerp-fiscal-rules/6.1-legacy for our customer pool we maintain under that 6.1 transitional branch.

Have a nice week end too and thanks again for the community work.

Revision history for this message
Niels Huylebroeck (red15) wrote :
Download full text (3.4 KiB)

I'd like to point out that the community process is working well for
bugfixing and minor improvements but development of a new module is
something that is probably moving too fast and creating large merges.

So I would suggest new module development is something you would keep on a
different branch, then when it's ready for deployment you can just copy (or
maybe using the extraction tools) the module into a community branch
(commits of development of new a new module is rarely interesting in bzr
history I think).

When the module is merged as a whole this of course will also create a
large merge, I would like to suggest that for easier reviewing and testing
by community that the unittests would be a good place to document features
and explain the workings of the module. Unittests are a good thing to have
anyway we can all agree ?

Considering budget constraints (we all have them) it's possible you didn't
create a unittest for a module that is relatively complex, the only
suggestion I would make is to at least write down in a simple textual
unittest which just has a @unittest2.skip("Needs code implementation")
decorator to show it's not yet implemented.

2013/1/18 Raphaël Valyi - http://www.akretion.com <email address hidden>

> @Joël,
>
> all right, let's say we will try it this way in the future and if it
> proves to be too bureaucratic, move to another group.
>
> By the way, even if we didn't pass through the official merge proposal
> ceremony, Renato and me peered on that (yes at 4 AM during a go live last
> month on the v6.1 branch; that's the reason we cannot afford more
> bureaucracy) so it's not like uncertain commits in the wild. That's isn't
> fundamentally different than 2 C2C developers approving each others...
>
> As for the reasons I didn't play the review game yet, it's certainly boils
> down to the fact that already investing on the branch extraction scripts
> was a huge investment for a light structure like us and as I said,
> migrating 15 000 lines of maturing locatization code to version 7.0 with
> only two people made us busy enough for not having the luxury to touch too
> much non localization related code these last months. I would happily peer
> with others for our localization. The issue is almost nobody here is making
> such serious investment on the localization, so we end up peering with
> ourselves so far. This situation is certainly related to the way OpenERP SA
> addresses this market that's why no matter how important the code is I
> never miss an occasion to give my opinion about the business model part of
> the project. At least we manage to peer for a few lower level modules we
> share with other localizations such as the Spanish one.
>
> Also as we respect the modules used in productions by others, you'll
> notice that we didn't make the offence of committing these things wildly
> into the 6.1 "stable" branch but rather maintained our own branch here
> instead
> https://code.launchpad.net/~akretion-team/openerp-fiscal-rules/6.1-legacyfor our customer pool we maintain under that 6.1 transitional branch.
>
> Have a nice week end too and thanks again for the community work.
> --
>
> https://code.launchpad.net/~ren...

Read more...

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

Can we please move this discussion to the openerp-community mailing list? Or wherever you like but not here, which is hardly appropriate.

Thanks.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_product_fiscal_classification/account_product_fiscal_classification.py'
2--- account_product_fiscal_classification/account_product_fiscal_classification.py 2012-10-29 13:41:30 +0000
3+++ account_product_fiscal_classification/account_product_fiscal_classification.py 2013-01-15 20:01:26 +0000
4@@ -23,174 +23,193 @@
5 from osv import fields, osv
6
7 class account_product_fiscal_classification(osv.osv):
8-
9 _name = 'account.product.fiscal.classification'
10 _description = 'Product Fiscal Classification'
11 _columns = {
12 'name': fields.char('Main code', size=32, required=True),
13 'description': fields.char('Description', size=64),
14 'company_id': fields.many2one('res.company', 'Company'),
15- #TODO restrict to company_id if company_id set when framework will allow it:
16- 'sale_base_tax_ids': fields.many2many('account.tax',
17- 'fiscal_classification_sale_tax_rel',
18- 'fiscal_classification_id', 'tax_id',
19- 'Base Sale Taxes',
20- domain=[('type_tax_use','!=','purchase')]),
21- 'purchase_base_tax_ids': fields.many2many('account.tax',
22- 'fiscal_classification_purchase_tax_rel',
23- 'fiscal_classification_id',
24- 'tax_id', 'Base Purchase Taxes',
25- domain=[('type_tax_use','!=','sale')]),
26- }
27-
28+ # TODO restrict to company_id if company_id set when
29+ # framework will allow it:
30+ 'sale_base_tax_ids': fields.many2many(
31+ 'account.tax', 'fiscal_classification_sale_tax_rel',
32+ 'fiscal_classification_id', 'tax_id', 'Base Sale Taxes',
33+ domain=[('type_tax_use', '!=', 'purchase')]),
34+ 'purchase_base_tax_ids': fields.many2many(
35+ 'account.tax', 'fiscal_classification_purchase_tax_rel',
36+ 'fiscal_classification_id', 'tax_id',
37+ 'Base Purchase Taxes',
38+ domain=[('type_tax_use', '!=', 'sale')])
39+ }
40+
41 def button_update_products(self, cr, uid, ids, context=None):
42
43 result = True
44- if not context:
45- context = {}
46+ if not context: context = {}
47
48- obj_product = self.pool.get('product.product')
49+ obj_product = self.pool.get('product.template')
50 obj_company = self.pool.get('res.company')
51
52 for fiscal_classification in self.browse(cr, uid, ids):
53- current_company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
54-
55- product_ids = obj_product.search(cr, uid, [])
56- product_read = obj_product.read(cr, uid, product_ids, ['property_fiscal_classification'])
57- product_ids_new = [x['id'] for x in product_read if x['property_fiscal_classification'] and x['property_fiscal_classification'][0] == fiscal_classification.id]
58-
59- for product in obj_product.browse(cr, uid, product_ids_new, context):
60- to_keep_sale_tax_ids = self.pool.get('account.tax').search(cr, uid, [('id', 'in', [x.id for x in product.taxes_id]), ('company_id', '!=', current_company_id)])
61- to_keep_purchase_tax_ids = self.pool.get('account.tax').search(cr, uid, [('id', 'in',[x.id for x in product.supplier_taxes_id]), ('company_id', '!=', current_company_id)])
62-
63+ property_ids = self.pool.get('ir.property').search(
64+ cr, uid, [('name', '=', 'property_fiscal_classification'),
65+ ('res_id', 'ilike', 'product.template,'),
66+ ('value_reference', '=', 'account.product.fiscal.classification,%s' % (fiscal_classification.id,))])
67+
68+ reads = self.pool.get('ir.property').read(
69+ cr, uid, property_ids, ['res_id'])
70+ product_ids = [int(l['res_id'].split(',')[1]) for l in reads]
71+ current_company_id = self.pool.get('res.users').browse(
72+ cr, uid, uid).company_id.id
73+
74+ for product in obj_product.browse(cr, uid, product_ids, context):
75+ to_keep_sale_tax_ids = self.pool.get('account.tax').search(
76+ cr, uid, [('id', 'in', [x.id for x in product.taxes_id]),
77+ ('company_id', '!=', current_company_id)])
78+
79+ to_keep_purchase_tax_ids = self.pool.get('account.tax').search(
80+ cr, uid, [('id', 'in', [x.id for x in product.supplier_taxes_id]),
81+ ('company_id', '!=', current_company_id)])
82+
83 vals = {
84- 'taxes_id': [(6, 0, to_keep_sale_tax_ids + [x.id for x in fiscal_classification.sale_base_tax_ids])],
85- 'supplier_taxes_id': [(6, 0, to_keep_purchase_tax_ids + [x.id for x in fiscal_classification.purchase_base_tax_ids])],
86+ 'taxes_id': [(6, 0, list(set(to_keep_sale_tax_ids + [x.id for x in fiscal_classification.sale_base_tax_ids])))],
87+ 'supplier_taxes_id': [(6, 0, list(set(to_keep_purchase_tax_ids + [x.id for x in fiscal_classification.purchase_base_tax_ids])))],
88 }
89-
90+
91 obj_product.write(cr, uid, product.id, vals, context)
92-
93+
94 return result
95-
96- def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=80):
97-
98- if not args:
99- args = []
100-
101- if not context:
102- context = {}
103+
104+ def name_search(self, cr, user, name='', args=None, operator='ilike',
105+ context=None, limit=80):
106+
107+ if not args: args = []
108+
109+ if not context: context = {}
110
111 if name:
112- ids = self.search(cr, user, [('name', '=', name)] + args, limit=limit, context=context)
113- if not len(ids):
114- ids = self.search(cr, user, [('description', '=', name)] + args, limit=limit, context=context)
115- if not len(ids):
116- ids = self.search(cr, user, [('name', operator, name)] + args, limit=limit, context=context)
117- ids += self.search(cr, user, [('description', operator, name)] + args, limit=limit, context=context)
118+ ids = self.search(cr, user, [('name', '=', name)] + args,
119+ limit=limit, context=context)
120+ if not len(ids):
121+ ids = self.search(
122+ cr, user, [('description', '=', name)] + args,
123+ limit=limit, context=context)
124+ if not len(ids):
125+ ids = self.search(cr, user, [('name', operator, name)] + args,
126+ limit=limit, context=context)
127+ ids += self.search(
128+ cr, user, [('description', operator, name)] + args,
129+ limit=limit, context=context)
130 else:
131 ids = self.search(cr, user, args, limit=limit, context=context)
132-
133+
134 return self.name_get(cr, user, ids, context)
135
136 account_product_fiscal_classification()
137
138+
139 class account_product_fiscal_classification_template(osv.osv):
140-
141 _name = 'account.product.fiscal.classification.template'
142 _description = 'Product Fiscal Classification Template'
143 _columns = {
144 'name': fields.char('Main code', size=32, required=True),
145 'description': fields.char('Description', size=64),
146- #TODO restrict to company_id if company_id set when framework will allow it:
147- 'sale_base_tax_ids': fields.many2many('account.tax.template',
148- 'fiscal_classification_template_sale_tax_rel',
149- 'fiscal_classification_id', 'tax_id',
150- 'Base Sale Taxes',
151- domain=[('type_tax_use','!=','purchase')]),
152- 'purchase_base_tax_ids': fields.many2many('account.tax.template',
153- 'fiscal_classification_template_purchase_tax_rel',
154- 'fiscal_classification_id',
155- 'tax_id', 'Base Purchase Taxes',
156- domain=[('type_tax_use','!=','sale')]),
157- }
158-
159- def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=80):
160-
161- if not args:
162- args = []
163-
164- if not context:
165- context = {}
166+ # TODO restrict to company_id if company_id set when
167+ # framework will allow it:
168+ 'sale_base_tax_ids': fields.many2many(
169+ 'account.tax.template',
170+ 'fiscal_classification_template_sale_tax_rel',
171+ 'fiscal_classification_id', 'tax_id',
172+ 'Base Sale Taxes',
173+ domain=[('type_tax_use', '!=', 'purchase')]),
174+ 'purchase_base_tax_ids': fields.many2many(
175+ 'account.tax.template',
176+ 'fiscal_classification_template_purchase_tax_rel',
177+ 'fiscal_classification_id',
178+ 'tax_id', 'Base Purchase Taxes',
179+ domain=[('type_tax_use', '!=', 'sale')]),
180+ }
181+
182+ def name_search(self, cr, user, name='', args=None, operator='ilike',
183+ context=None, limit=80):
184+
185+ if not args: args = []
186+
187+ if not context: context = {}
188
189 if name:
190- ids = self.search(cr, user, [('name', '=', name)] + args, limit=limit, context=context)
191- if not len(ids):
192- ids = self.search(cr, user, [('description', '=', name)] + args, limit=limit, context=context)
193- if not len(ids):
194- ids = self.search(cr, user, [('name', operator, name)] + args, limit=limit, context=context)
195- ids += self.search(cr, user, [('description', operator, name)] + args, limit=limit, context=context)
196+ ids = self.search(cr, user, [('name', '=', name)] + args,
197+ limit=limit, context=context)
198+ if not len(ids):
199+ ids = self.search(
200+ cr, user, [('description', '=', name)] + args,
201+ limit=limit, context=context)
202+ if not len(ids):
203+ ids = self.search(cr, user, [('name', operator, name)] + args,
204+ limit=limit, context=context)
205+ ids += self.search(
206+ cr, user, [('description', operator, name)] + args,
207+ limit=limit, context=context)
208 else:
209 ids = self.search(cr, user, args, limit=limit, context=context)
210-
211+
212 return self.name_get(cr, user, ids, context)
213
214 account_product_fiscal_classification_template()
215
216+
217 class wizard_account_product_fiscal_classification(osv.osv_memory):
218-
219 _name='wizard.account.product.fiscal.classification'
220-
221 _columns = {
222- 'company_id':fields.many2one('res.company','Company', required=True),
223- }
224-
225+ 'company_id': fields.many2one('res.company','Company', required=True),
226+ }
227 _defaults = {
228- 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr,uid,[uid],c)[0].company_id.id,
229- }
230+ 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr,uid,[uid],c)[0].company_id.id,
231+ }
232
233 def action_create(self, cr, uid, ids, context=None):
234-
235 obj_wizard = self.browse(cr,uid,ids[0])
236 obj_tax = self.pool.get('account.tax')
237 obj_tax_template = self.pool.get('account.tax.template')
238- obj_fiscal_classification = self.pool.get('account.product.fiscal.classification')
239- obj_fiscal_classification_template = self.pool.get('account.product.fiscal.classification.template')
240+ obj_fc = self.pool.get('account.product.fiscal.classification')
241+ obj_fc_template = self.pool.get('account.product.fiscal.classification.template')
242
243 company_id = obj_wizard.company_id.id
244 tax_template_ref = {}
245-
246+
247 tax_ids = obj_tax.search(cr,uid,[('company_id','=',company_id)])
248-
249+
250 for tax in obj_tax.browse(cr,uid,tax_ids):
251 tax_template = obj_tax_template.search(cr,uid,[('name','=',tax.name)])[0]
252-
253+
254 if tax_template:
255 tax_template_ref[tax_template] = tax.id
256-
257- fclass_ids_template = obj_fiscal_classification_template.search(cr, uid, [])
258-
259- for fclass_template in obj_fiscal_classification_template.browse(cr, uid, fclass_ids_template):
260-
261- fclass_id = obj_fiscal_classification.search(cr, uid, [('name','=',fclass_template.name)])
262-
263- if not fclass_id:
264+
265+ fclass_ids_template = obj_fc_template.search(cr, uid, [])
266+
267+ for fclass_template in obj_fc_template.browse(cr, uid, fclass_ids_template):
268+
269+ fclass_id = obj_fc.search(cr, uid, [('name','=',fclass_template.name)])
270+
271+ if not fclass_id:
272 sale_tax_ids = []
273 for tax in fclass_template.sale_base_tax_ids:
274 sale_tax_ids.append(tax_template_ref[tax.id])
275-
276+
277 purchase_tax_ids = []
278 for tax in fclass_template.purchase_base_tax_ids:
279 purchase_tax_ids.append(tax_template_ref[tax.id])
280-
281+
282 vals = {
283- 'name': fclass_template.name,
284- 'description': fclass_template.description,
285- 'company_id': company_id,
286- 'sale_base_tax_ids': [(6,0, sale_tax_ids)],
287- 'purchase_base_tax_ids': [(6,0, purchase_tax_ids)]
288- }
289- obj_fiscal_classification.create(cr,uid,vals)
290-
291+ 'name': fclass_template.name,
292+ 'description': fclass_template.description,
293+ 'company_id': company_id,
294+ 'sale_base_tax_ids': [(6, 0, sale_tax_ids)],
295+ 'purchase_base_tax_ids': [(6, 0, purchase_tax_ids)]
296+ }
297+ obj_fc.create(cr,uid,vals)
298+
299 return {}
300
301 wizard_account_product_fiscal_classification()
302+
303
304=== modified file 'account_product_fiscal_classification/account_product_fiscal_classification_view.xml'
305--- account_product_fiscal_classification/account_product_fiscal_classification_view.xml 2012-12-05 19:41:36 +0000
306+++ account_product_fiscal_classification/account_product_fiscal_classification_view.xml 2013-01-15 20:01:26 +0000
307@@ -5,7 +5,6 @@
308 <record model="ir.ui.view" id="fiscal_classification_normal_form_view_form">
309 <field name="name">fiscal_classification_normal_form_view_form</field>
310 <field name="model">account.product.fiscal.classification</field>
311- <field name="type">form</field>
312 <field name="arch" type="xml">
313 <form string="Fiscal Classification">
314 <field name="name"/>
315@@ -24,12 +23,11 @@
316 <record model="ir.ui.view" id="fiscal_classification_normal_form_view_tree">
317 <field name="name">fiscal_classification_normal_form_view_tree</field>
318 <field name="model">account.product.fiscal.classification</field>
319- <field name="type">tree</field>
320 <field name="arch" type="xml">
321 <tree string="Fiscal Classification">
322- <field select="1" name="name"/>
323+ <field name="name"/>
324 <field name="description"/>
325- <field select="1" name="company_id"/>
326+ <field name="company_id"/>
327 </tree>
328 </field>
329 </record>
330@@ -37,7 +35,6 @@
331 <record model="ir.ui.view" id="fiscal_classification_template_normal_form_view_form">
332 <field name="name">fiscal_classification_template_normal_form_view_form</field>
333 <field name="model">account.product.fiscal.classification.template</field>
334- <field name="type">form</field>
335 <field name="arch" type="xml">
336 <form string="Fiscal Classification Template">
337 <field name="name"/>
338@@ -54,10 +51,9 @@
339 <record model="ir.ui.view" id="fiscal_classification_template_normal_form_view_tree">
340 <field name="name">fiscal_classification_normal_form_view_tree</field>
341 <field name="model">account.product.fiscal.classification.template</field>
342- <field name="type">tree</field>
343 <field name="arch" type="xml">
344- <tree string="Fiscal Classification Templates">
345- <field select="1" name="name"/>
346+ <tree string="Fiscal Classification Template">
347+ <field name="name"/>
348 <field name="description"/>
349 </tree>
350 </field>
351@@ -68,7 +64,6 @@
352 <record id="view_wizard_account_product_fiscal_classification" model="ir.ui.view">
353 <field name="name">Generate Product Fiscal Classification from Templates</field>
354 <field name="model">wizard.account.product.fiscal.classification</field>
355- <field name="type">form</field>
356 <field name="arch" type="xml">
357 <form string="Generate Product Fiscal Classification from Templates">
358 <separator col="4" colspan="4" string="Generate Product Fiscal Classification from Templates"/>
359
360=== modified file 'account_product_fiscal_classification/product.py'
361--- account_product_fiscal_classification/product.py 2012-10-29 13:41:30 +0000
362+++ account_product_fiscal_classification/product.py 2013-01-15 20:01:26 +0000
363@@ -22,9 +22,8 @@
364
365 from osv import fields, osv
366
367-class product_template(osv.osv):
368+class product_template(osv.Model):
369 _inherit = 'product.template'
370-
371 _columns = {
372 'property_fiscal_classification': fields.property(
373 'account.product.fiscal.classification',
374@@ -34,7 +33,7 @@
375 method=True,
376 view_load=True,
377 help="Company wise (eg localizable) Fiscal Classification"),
378- }
379+ }
380
381 def fiscal_classification_id_change(self, cr, uid, ids, fiscal_classification_id=False, sale_tax_ids=[[6, 0, []]], purchase_tax_ids=[[6, 0, []]]):
382 """We eventually keep the sale and purchase taxes because those are not company wise in OpenERP. So if we choose a different fiscal position
383@@ -47,13 +46,14 @@
384 to_keep_sale_tax_ids = self.pool.get('account.tax').search(cr, uid, [('id', 'in', sale_tax_ids[0][2]), ('company_id', '!=', current_company_id)])
385 to_keep_purchase_tax_ids = self.pool.get('account.tax').search(cr, uid, [('id', 'in', purchase_tax_ids[0][2]), ('company_id', '!=', current_company_id)])
386
387- result['value']['taxes_id'] = to_keep_sale_tax_ids + [x.id for x in fiscal_classification.sale_base_tax_ids]
388- result['value']['supplier_taxes_id'] = to_keep_purchase_tax_ids + [x.id for x in fiscal_classification.purchase_base_tax_ids]
389+ result['value']['taxes_id'] = list(set(to_keep_sale_tax_ids + [x.id for x in fiscal_classification.sale_base_tax_ids]))
390+ result['value']['supplier_taxes_id'] = list(set(to_keep_purchase_tax_ids + [x.id for x in fiscal_classification.purchase_base_tax_ids]))
391 return result
392
393 product_template()
394
395-class product_product(osv.osv):
396+
397+class product_product(osv.Model):
398 _inherit = "product.product"
399
400 def fiscal_classification_id_change(self, cr, uid, ids, fiscal_classification_id=False, sale_tax_ids=[[6, 0, []]], purchase_tax_ids=[[6, 0, []]]):
401@@ -64,5 +64,3 @@
402 return result
403
404 product_product()
405-
406-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
407
408=== modified file 'account_product_fiscal_classification/product_view.xml'
409--- account_product_fiscal_classification/product_view.xml 2012-12-07 04:37:44 +0000
410+++ account_product_fiscal_classification/product_view.xml 2013-01-15 20:01:26 +0000
411@@ -8,7 +8,7 @@
412 <field name="inherit_id" ref="account.product_normal_form_view"/>
413 <field name="arch" type="xml">
414 <field name="property_account_expense" position="after">
415- <separator string="Fiscal Properties" colspan="4"/>
416+ <separator string="Fiscal Properties" colspan="4"/>
417 <field name="property_fiscal_classification" colspan="4" attrs="{'required': [('type', '!=', 'service')]}" select="2" on_change="fiscal_classification_id_change(property_fiscal_classification, taxes_id, supplier_taxes_id)"/>
418 </field>
419 </field>