Merge lp:~akretion-team/account-financial-tools/70-fiscal-position-check-vat into lp:~account-core-editors/account-financial-tools/7.0
- 70-fiscal-position-check-vat
- Merge into 7.0
Status: | Merged |
---|---|
Merge reported by: | Raphaël Valyi - http://www.akretion.com |
Merged at revision: | not available |
Proposed branch: | lp:~akretion-team/account-financial-tools/70-fiscal-position-check-vat |
Merge into: | lp:~account-core-editors/account-financial-tools/7.0 |
Diff against target: |
443 lines (+397/-0) 8 files modified
account_fiscal_position_vat_check/__init__.py (+24/-0) account_fiscal_position_vat_check/__openerp__.py (+56/-0) account_fiscal_position_vat_check/account_fiscal_position_view.xml (+37/-0) account_fiscal_position_vat_check/account_invoice.py (+58/-0) account_fiscal_position_vat_check/i18n/account_fiscal_position_vat_check.pot (+78/-0) account_fiscal_position_vat_check/i18n/fr.po (+78/-0) account_fiscal_position_vat_check/partner.py (+40/-0) account_fiscal_position_vat_check/partner_view.xml (+26/-0) |
To merge this branch: | bzr merge lp:~akretion-team/account-financial-tools/70-fiscal-position-check-vat |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guewen Baconnier @ Camptocamp | Needs Resubmitting | ||
Pedro Manuel Baeza | code review and test | Approve | |
Frederic Clementi - Camptocamp (community) | functional - no code review | Approve | |
Review via email: mp+186515@code.launchpad.net |
Commit message
Description of the change
Add a module "account_
Extracts from the description of the module :
<<
This module adds an option **Customer must have VAT** on fiscal positions. When a user tries to validate a customer invoice or refund with a fiscal position that have this option, OpenERP will check that the customer has a VAT number. If it doesn't, OpenERP will block the validation of the invoice and display an error message.
In the European Union (EU), when an EU company sends an invoice to another EU company in another country, it can invoice without VAT (most of the time) but the VAT number of the customer must be displayed on the invoice.
>>
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Frederic Clementi - Camptocamp (frederic-clementi) wrote : | # |
LGTM
- 2. By Alexis de Lattre
-
Coding style enhancements suggested by the reviewers.
- 3. By Alexis de Lattre
-
Should be PEP8 compliant now.
Alexis de Lattre (alexis-via) wrote : | # |
@Pedro
The code style is OK for you now ?
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Hi, Alexis, thank you very much for the changes!
I have tested the module and it works correctly.
Please make a last change: rename translation template file to .pot, to get automatically recognised by Launchpad Rosetta.
Regards.
- 4. By Alexis de Lattre
-
Translation template file is .pot (it's a trap, because OpenERP generate the file with .po extension !)
- 5. By Alexis de Lattre
-
Add warning when the user sets a fiscal position "must have vat" on a partner and this partner doesn't have a VAT number in openerp yet.
Remove the cut at 80 lines on some messages as it doesn't work with translation files.
Update FR translation.
Alexis de Lattre (alexis-via) wrote : | # |
About revno 5 : I had recently a new idea for this module : add an on_change on the fiscal position of res.partner : when you switch to a fiscal position that have "must have VAT" and the partner doesn't have a VAT, you get a warning pop-up.
I have checked everything again, including translations.
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Thanks, Alexis,
Your changes are working good, but please let changes of this size for another MP instead of doing them in the middle of the MP, because first 'Approve' doesn't count for the second change, confusing anyone that see the overview.
Regards.
- 6. By Alexis de Lattre
-
Only display a warning when the partner is a customer.
I promise, it's my last commit on this merge proposal :)
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) : | # |
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Hi Alexis, I tried to merge your branch in lp:account-financial-tools/7.0 but I get:
bzr: ERROR: Branches have no common ancestor, and no merge base revision was specified.
Can you check?
Alexis de Lattre (alexis-via) wrote : | # |
My branch only contains my module, it's not a "full" branch. So a bzr replay should work, but a merge doesn't work. If it's a problem, I will prepare a "full" branch of account-
Preview Diff
1 | === added directory 'account_fiscal_position_vat_check' |
2 | === added file 'account_fiscal_position_vat_check/__init__.py' |
3 | --- account_fiscal_position_vat_check/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ account_fiscal_position_vat_check/__init__.py 2013-10-24 16:19:16 +0000 |
5 | @@ -0,0 +1,24 @@ |
6 | +# -*- encoding: utf-8 -*- |
7 | +############################################################################## |
8 | +# |
9 | +# Account Fiscal Position VAT Check module for OpenERP |
10 | +# Copyright (C) 2013 Akretion (http://www.akretion.com) |
11 | +# @author Alexis de Lattre <alexis.delattre@akretion.com> |
12 | +# |
13 | +# This program is free software: you can redistribute it and/or modify |
14 | +# it under the terms of the GNU Affero General Public License as |
15 | +# published by the Free Software Foundation, either version 3 of the |
16 | +# License, or (at your option) any later version. |
17 | +# |
18 | +# This program is distributed in the hope that it will be useful, |
19 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | +# GNU Affero General Public License for more details. |
22 | +# |
23 | +# You should have received a copy of the GNU Affero General Public License |
24 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
25 | +# |
26 | +############################################################################## |
27 | + |
28 | +from . import account_invoice |
29 | +from . import partner |
30 | |
31 | === added file 'account_fiscal_position_vat_check/__openerp__.py' |
32 | --- account_fiscal_position_vat_check/__openerp__.py 1970-01-01 00:00:00 +0000 |
33 | +++ account_fiscal_position_vat_check/__openerp__.py 2013-10-24 16:19:16 +0000 |
34 | @@ -0,0 +1,56 @@ |
35 | +# -*- encoding: utf-8 -*- |
36 | +############################################################################## |
37 | +# |
38 | +# Account Fiscal Position VAT Check module for OpenERP |
39 | +# Copyright (C) 2013 Akretion (http://www.akretion.com) |
40 | +# @author Alexis de Lattre <alexis.delattre@akretion.com> |
41 | +# |
42 | +# This program is free software: you can redistribute it and/or modify |
43 | +# it under the terms of the GNU Affero General Public License as |
44 | +# published by the Free Software Foundation, either version 3 of the |
45 | +# License, or (at your option) any later version. |
46 | +# |
47 | +# This program is distributed in the hope that it will be useful, |
48 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
49 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
50 | +# GNU Affero General Public License for more details. |
51 | +# |
52 | +# You should have received a copy of the GNU Affero General Public License |
53 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
54 | +# |
55 | +############################################################################## |
56 | + |
57 | + |
58 | +{ |
59 | + 'name': 'Account Fiscal Position VAT Check', |
60 | + 'version': '0.1', |
61 | + 'category': 'Accounting & Finance', |
62 | + 'license': 'AGPL-3', |
63 | + 'summary': 'Check VAT on invoice validation', |
64 | + 'description': """ |
65 | +Check that the Customer has a VAT number on invoice validation |
66 | +============================================================== |
67 | + |
68 | +This module adds an option **Customer must have VAT** on fiscal positions. When a user tries to validate a customer invoice or refund with a fiscal position that have this option, OpenERP will check that the customer has a VAT number. If it doesn't, OpenERP will block the validation of the invoice and display an error message. |
69 | + |
70 | +In the European Union (EU), when an EU company sends an invoice to another EU company in another country, it can invoice without VAT (most of the time) but the VAT number of the customer must be displayed on the invoice. |
71 | + |
72 | +This module also displays a warning when a user sets a fiscal position with the option **Customer must have VAT** on a customer and this customer doesn't have a VAT number in OpenERP yet. |
73 | + |
74 | +Please contact Alexis de Lattre from Akretion <alexis.delattre@akretion.com> for any help or question about this module. |
75 | + """, |
76 | + 'author': 'Akretion', |
77 | + 'website': 'http://www.akretion.com', |
78 | + 'depends': ['account'], |
79 | + 'data': [ |
80 | + 'account_fiscal_position_view.xml', |
81 | + 'partner_view.xml', |
82 | + ], |
83 | + 'images': [ |
84 | + 'fiscal_position_form.jpg', |
85 | + 'vat_check_invoice_validation.jpg', |
86 | + ], |
87 | + 'installable': True, |
88 | + 'active': False, |
89 | + 'application': True, |
90 | +} |
91 | |
92 | === added file 'account_fiscal_position_vat_check/account_fiscal_position_view.xml' |
93 | --- account_fiscal_position_vat_check/account_fiscal_position_view.xml 1970-01-01 00:00:00 +0000 |
94 | +++ account_fiscal_position_vat_check/account_fiscal_position_view.xml 2013-10-24 16:19:16 +0000 |
95 | @@ -0,0 +1,37 @@ |
96 | +<?xml version="1.0" encoding="utf-8"?> |
97 | + |
98 | +<!-- |
99 | + Copyright (C) 2013 Akretion (http://www.akretion.com/) |
100 | + @author Alexis de Lattre <alexis.delattre@akretion.com> |
101 | + The licence is in the file __openerp__.py |
102 | +--> |
103 | + |
104 | +<openerp> |
105 | +<data> |
106 | + |
107 | + |
108 | +<record id="view_account_position_form" model="ir.ui.view"> |
109 | + <field name="name">customer.must.have.vat.fiscal_position_form</field> |
110 | + <field name="model">account.fiscal.position</field> |
111 | + <field name="inherit_id" ref="account.view_account_position_form" /> |
112 | + <field name="arch" type="xml"> |
113 | + <field name="active" position="after"> |
114 | + <field name="customer_must_have_vat" /> |
115 | + </field> |
116 | + </field> |
117 | +</record> |
118 | + |
119 | + |
120 | +<record id="view_account_position_tree" model="ir.ui.view"> |
121 | + <field name="name">customer.must.have.vat.fiscal_position_tree</field> |
122 | + <field name="model">account.fiscal.position</field> |
123 | + <field name="inherit_id" ref="account.view_account_position_tree" /> |
124 | + <field name="arch" type="xml"> |
125 | + <field name="name" position="after"> |
126 | + <field name="customer_must_have_vat" /> |
127 | + </field> |
128 | + </field> |
129 | +</record> |
130 | + |
131 | +</data> |
132 | +</openerp> |
133 | |
134 | === added file 'account_fiscal_position_vat_check/account_invoice.py' |
135 | --- account_fiscal_position_vat_check/account_invoice.py 1970-01-01 00:00:00 +0000 |
136 | +++ account_fiscal_position_vat_check/account_invoice.py 2013-10-24 16:19:16 +0000 |
137 | @@ -0,0 +1,58 @@ |
138 | +# -*- encoding: utf-8 -*- |
139 | +############################################################################## |
140 | +# |
141 | +# Account Fiscal Position VAT Check module for OpenERP |
142 | +# Copyright (C) 2013 Akretion (http://www.akretion.com) |
143 | +# @author Alexis de Lattre <alexis.delattre@akretion.com> |
144 | +# |
145 | +# This program is free software: you can redistribute it and/or modify |
146 | +# it under the terms of the GNU Affero General Public License as |
147 | +# published by the Free Software Foundation, either version 3 of the |
148 | +# License, or (at your option) any later version. |
149 | +# |
150 | +# This program is distributed in the hope that it will be useful, |
151 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
152 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
153 | +# GNU Affero General Public License for more details. |
154 | +# |
155 | +# You should have received a copy of the GNU Affero General Public License |
156 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
157 | +# |
158 | +############################################################################## |
159 | + |
160 | +from openerp.osv import orm, fields |
161 | +from openerp.tools.translate import _ |
162 | + |
163 | + |
164 | +class account_fiscal_position(orm.Model): |
165 | + _inherit = 'account.fiscal.position' |
166 | + |
167 | + _columns = { |
168 | + 'customer_must_have_vat': fields.boolean( |
169 | + 'Customer Must Have VAT number', |
170 | + help="If enabled, OpenERP will check that the customer has a VAT number when the user validates a customer invoice/refund."), |
171 | + } |
172 | + |
173 | + |
174 | +class account_invoice(orm.Model): |
175 | + _inherit = 'account.invoice' |
176 | + |
177 | + def action_move_create(self, cr, uid, ids, context=None): |
178 | + '''Check that the customer has VAT set |
179 | + if required by the fiscal position''' |
180 | + for invoice in self.browse(cr, uid, ids, context=context): |
181 | + if invoice.type in ('out_invoice', 'out_refund') \ |
182 | + and invoice.fiscal_position \ |
183 | + and invoice.fiscal_position.customer_must_have_vat \ |
184 | + and not invoice.partner_id.vat: |
185 | + if invoice.type == 'out_invoice': |
186 | + type_label = _('a Customer Invoice') |
187 | + else: |
188 | + type_label = _('a Customer Refund') |
189 | + raise orm.except_orm( |
190 | + _('Missing VAT number:'), |
191 | + _("You are trying to validate %s with the fiscal position '%s' that require the customer to have a VAT number. But the Customer '%s' doesn't have a VAT number in OpenERP. Please add the VAT number of this Customer in OpenERP and try to validate again.") |
192 | + % (type_label, invoice.fiscal_position.name, |
193 | + invoice.partner_id.name)) |
194 | + return super(account_invoice, self).action_move_create( |
195 | + cr, uid, ids, context=context) |
196 | |
197 | === added directory 'account_fiscal_position_vat_check/i18n' |
198 | === added file 'account_fiscal_position_vat_check/i18n/account_fiscal_position_vat_check.pot' |
199 | --- account_fiscal_position_vat_check/i18n/account_fiscal_position_vat_check.pot 1970-01-01 00:00:00 +0000 |
200 | +++ account_fiscal_position_vat_check/i18n/account_fiscal_position_vat_check.pot 2013-10-24 16:19:16 +0000 |
201 | @@ -0,0 +1,78 @@ |
202 | +# Translation of OpenERP Server. |
203 | +# This file contains the translation of the following modules: |
204 | +# * account_fiscal_position_vat_check |
205 | +# |
206 | +msgid "" |
207 | +msgstr "" |
208 | +"Project-Id-Version: OpenERP Server 7.0\n" |
209 | +"Report-Msgid-Bugs-To: \n" |
210 | +"POT-Creation-Date: 2013-10-19 19:46+0000\n" |
211 | +"PO-Revision-Date: 2013-10-19 19:46+0000\n" |
212 | +"Last-Translator: <>\n" |
213 | +"Language-Team: \n" |
214 | +"MIME-Version: 1.0\n" |
215 | +"Content-Type: text/plain; charset=UTF-8\n" |
216 | +"Content-Transfer-Encoding: \n" |
217 | +"Plural-Forms: \n" |
218 | + |
219 | +#. module: account_fiscal_position_vat_check |
220 | +#: view:res.partner:0 |
221 | +msgid "fiscal_position_change(property_account_position, vat)" |
222 | +msgstr "" |
223 | + |
224 | +#. module: account_fiscal_position_vat_check |
225 | +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:54 |
226 | +#, python-format |
227 | +msgid "You are trying to validate %s with the fiscal position '%s' that require the customer to have a VAT number. But the Customer '%s' doesn't have a VAT number in OpenERP. Please add the VAT number of this Customer in OpenERP and try to validate again." |
228 | +msgstr "" |
229 | + |
230 | +#. module: account_fiscal_position_vat_check |
231 | +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:51 |
232 | +#, python-format |
233 | +msgid "a Customer Refund" |
234 | +msgstr "" |
235 | + |
236 | +#. module: account_fiscal_position_vat_check |
237 | +#: field:account.fiscal.position,customer_must_have_vat:0 |
238 | +msgid "Customer Must Have VAT number" |
239 | +msgstr "" |
240 | + |
241 | +#. module: account_fiscal_position_vat_check |
242 | +#: help:account.fiscal.position,customer_must_have_vat:0 |
243 | +msgid "If enabled, OpenERP will check that the customer has a VAT number when the user validates a customer invoice/refund." |
244 | +msgstr "" |
245 | + |
246 | +#. module: account_fiscal_position_vat_check |
247 | +#: model:ir.model,name:account_fiscal_position_vat_check.model_account_fiscal_position |
248 | +msgid "Fiscal Position" |
249 | +msgstr "" |
250 | + |
251 | +#. module: account_fiscal_position_vat_check |
252 | +#: model:ir.model,name:account_fiscal_position_vat_check.model_account_invoice |
253 | +msgid "Invoice" |
254 | +msgstr "" |
255 | + |
256 | +#. module: account_fiscal_position_vat_check |
257 | +#: model:ir.model,name:account_fiscal_position_vat_check.model_res_partner |
258 | +msgid "Partner" |
259 | +msgstr "" |
260 | + |
261 | +#. module: account_fiscal_position_vat_check |
262 | +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:49 |
263 | +#, python-format |
264 | +msgid "a Customer Invoice" |
265 | +msgstr "" |
266 | + |
267 | +#. module: account_fiscal_position_vat_check |
268 | +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:53 |
269 | +#: code:addons/account_fiscal_position_vat_check/partner.py:38 |
270 | +#, python-format |
271 | +msgid "Missing VAT number:" |
272 | +msgstr "" |
273 | + |
274 | +#. module: account_fiscal_position_vat_check |
275 | +#: code:addons/account_fiscal_position_vat_check/partner.py:39 |
276 | +#, python-format |
277 | +msgid "You have set the fiscal position '%s' that require the customer to have a VAT number. You should add the VAT number of this customer in OpenERP." |
278 | +msgstr "" |
279 | + |
280 | |
281 | === added file 'account_fiscal_position_vat_check/i18n/fr.po' |
282 | --- account_fiscal_position_vat_check/i18n/fr.po 1970-01-01 00:00:00 +0000 |
283 | +++ account_fiscal_position_vat_check/i18n/fr.po 2013-10-24 16:19:16 +0000 |
284 | @@ -0,0 +1,78 @@ |
285 | +# Translation of OpenERP Server. |
286 | +# This file contains the translation of the following modules: |
287 | +# * account_fiscal_position_vat_check |
288 | +# |
289 | +msgid "" |
290 | +msgstr "" |
291 | +"Project-Id-Version: OpenERP Server 7.0\n" |
292 | +"Report-Msgid-Bugs-To: \n" |
293 | +"POT-Creation-Date: 2013-10-19 19:47+0000\n" |
294 | +"PO-Revision-Date: 2013-10-19 19:47+0000\n" |
295 | +"Last-Translator: <>\n" |
296 | +"Language-Team: \n" |
297 | +"MIME-Version: 1.0\n" |
298 | +"Content-Type: text/plain; charset=UTF-8\n" |
299 | +"Content-Transfer-Encoding: \n" |
300 | +"Plural-Forms: \n" |
301 | + |
302 | +#. module: account_fiscal_position_vat_check |
303 | +#: view:res.partner:0 |
304 | +msgid "fiscal_position_change(property_account_position, vat)" |
305 | +msgstr "fiscal_position_change(property_account_position, vat)" |
306 | + |
307 | +#. module: account_fiscal_position_vat_check |
308 | +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:54 |
309 | +#, python-format |
310 | +msgid "You are trying to validate %s with the fiscal position '%s' that require the customer to have a VAT number. But the Customer '%s' doesn't have a VAT number in OpenERP. Please add the VAT number of this Customer in OpenERP and try to validate again." |
311 | +msgstr "Vous essayez de valider %s avec la position fiscale '%s' qui oblige à connaître le numéro de TVA du client. Mais le client '%s' n'a pas de numéro de TVA dans OpenERP. Veuillez ajouter le numéro de TVA de ce client dans OpenERP et essayer de valider à nouveau." |
312 | + |
313 | +#. module: account_fiscal_position_vat_check |
314 | +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:51 |
315 | +#, python-format |
316 | +msgid "a Customer Refund" |
317 | +msgstr "un avoir client" |
318 | + |
319 | +#. module: account_fiscal_position_vat_check |
320 | +#: field:account.fiscal.position,customer_must_have_vat:0 |
321 | +msgid "Customer Must Have VAT number" |
322 | +msgstr "Numéro de TVA obligatoire pour le client" |
323 | + |
324 | +#. module: account_fiscal_position_vat_check |
325 | +#: help:account.fiscal.position,customer_must_have_vat:0 |
326 | +msgid "If enabled, OpenERP will check that the customer has a VAT number when the user validates a customer invoice/refund." |
327 | +msgstr "Si activé, OpenERP vérifiera que le client a un numéro de TVA quand l'utilisasteur valide la facture/avoir client." |
328 | + |
329 | +#. module: account_fiscal_position_vat_check |
330 | +#: model:ir.model,name:account_fiscal_position_vat_check.model_account_fiscal_position |
331 | +msgid "Fiscal Position" |
332 | +msgstr "Position fiscale" |
333 | + |
334 | +#. module: account_fiscal_position_vat_check |
335 | +#: model:ir.model,name:account_fiscal_position_vat_check.model_account_invoice |
336 | +msgid "Invoice" |
337 | +msgstr "Facture" |
338 | + |
339 | +#. module: account_fiscal_position_vat_check |
340 | +#: model:ir.model,name:account_fiscal_position_vat_check.model_res_partner |
341 | +msgid "Partner" |
342 | +msgstr "Partenaire" |
343 | + |
344 | +#. module: account_fiscal_position_vat_check |
345 | +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:49 |
346 | +#, python-format |
347 | +msgid "a Customer Invoice" |
348 | +msgstr "une facture client" |
349 | + |
350 | +#. module: account_fiscal_position_vat_check |
351 | +#: code:addons/account_fiscal_position_vat_check/account_invoice.py:53 |
352 | +#: code:addons/account_fiscal_position_vat_check/partner.py:38 |
353 | +#, python-format |
354 | +msgid "Missing VAT number:" |
355 | +msgstr "Numéro de TVA manquant :" |
356 | + |
357 | +#. module: account_fiscal_position_vat_check |
358 | +#: code:addons/account_fiscal_position_vat_check/partner.py:39 |
359 | +#, python-format |
360 | +msgid "You have set the fiscal position '%s' that require the customer to have a VAT number. You should add the VAT number of this customer in OpenERP." |
361 | +msgstr "Vous avez sélectionné la position fiscale '%s' qui exige que le client ait un numéro de TVA. Vous devez ajouter le numéro de TVA de ce client dans OpenERP." |
362 | + |
363 | |
364 | === added directory 'account_fiscal_position_vat_check/images' |
365 | === added file 'account_fiscal_position_vat_check/images/fiscal_position_form.jpg' |
366 | Binary files account_fiscal_position_vat_check/images/fiscal_position_form.jpg 1970-01-01 00:00:00 +0000 and account_fiscal_position_vat_check/images/fiscal_position_form.jpg 2013-10-24 16:19:16 +0000 differ |
367 | === added file 'account_fiscal_position_vat_check/images/vat_check_invoice_validation.jpg' |
368 | Binary files account_fiscal_position_vat_check/images/vat_check_invoice_validation.jpg 1970-01-01 00:00:00 +0000 and account_fiscal_position_vat_check/images/vat_check_invoice_validation.jpg 2013-10-24 16:19:16 +0000 differ |
369 | === added file 'account_fiscal_position_vat_check/partner.py' |
370 | --- account_fiscal_position_vat_check/partner.py 1970-01-01 00:00:00 +0000 |
371 | +++ account_fiscal_position_vat_check/partner.py 2013-10-24 16:19:16 +0000 |
372 | @@ -0,0 +1,40 @@ |
373 | +# -*- encoding: utf-8 -*- |
374 | +############################################################################## |
375 | +# |
376 | +# Account Fiscal Position VAT Check module for OpenERP |
377 | +# Copyright (C) 2013 Akretion (http://www.akretion.com) |
378 | +# @author Alexis de Lattre <alexis.delattre@akretion.com> |
379 | +# |
380 | +# This program is free software: you can redistribute it and/or modify |
381 | +# it under the terms of the GNU Affero General Public License as |
382 | +# published by the Free Software Foundation, either version 3 of the |
383 | +# License, or (at your option) any later version. |
384 | +# |
385 | +# This program is distributed in the hope that it will be useful, |
386 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
387 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
388 | +# GNU Affero General Public License for more details. |
389 | +# |
390 | +# You should have received a copy of the GNU Affero General Public License |
391 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
392 | +# |
393 | +############################################################################## |
394 | + |
395 | +from openerp.osv import orm |
396 | +from openerp.tools.translate import _ |
397 | + |
398 | + |
399 | +class res_partner(orm.Model): |
400 | + _inherit = 'res.partner' |
401 | + |
402 | + def fiscal_position_change(self, cr, uid, ids, account_position, vat, customer): |
403 | + '''Warning is the fiscal position requires a vat number and the partner |
404 | + doesn't have one yet''' |
405 | + if account_position and customer and not vat: |
406 | + fp = self.pool['account.fiscal.position'].read( |
407 | + cr, uid, account_position, ['customer_must_have_vat', 'name']) |
408 | + if fp['customer_must_have_vat']: |
409 | + return {'warning': { |
410 | + 'title': _('Missing VAT number:'), |
411 | + 'message': _("You have set the fiscal position '%s' that require the customer to have a VAT number. You should add the VAT number of this customer in OpenERP.") % fp['name']}} |
412 | + return True |
413 | |
414 | === added file 'account_fiscal_position_vat_check/partner_view.xml' |
415 | --- account_fiscal_position_vat_check/partner_view.xml 1970-01-01 00:00:00 +0000 |
416 | +++ account_fiscal_position_vat_check/partner_view.xml 2013-10-24 16:19:16 +0000 |
417 | @@ -0,0 +1,26 @@ |
418 | +<?xml version="1.0" encoding="utf-8"?> |
419 | + |
420 | +<!-- |
421 | + Copyright (C) 2013 Akretion (http://www.akretion.com/) |
422 | + @author Alexis de Lattre <alexis.delattre@akretion.com> |
423 | + The licence is in the file __openerp__.py |
424 | +--> |
425 | + |
426 | +<openerp> |
427 | +<data> |
428 | + |
429 | + |
430 | +<record id="view_partner_property_form" model="ir.ui.view"> |
431 | + <field name="name">customer.must.have.vat.fiscal_position_form</field> |
432 | + <field name="model">res.partner</field> |
433 | + <field name="inherit_id" ref="account.view_partner_property_form" /> |
434 | + <field name="arch" type="xml"> |
435 | + <field name="property_account_position" position="attributes"> |
436 | + <attribute name="on_change">fiscal_position_change(property_account_position, vat, customer)</attribute> |
437 | + </field> |
438 | + </field> |
439 | +</record> |
440 | + |
441 | + |
442 | +</data> |
443 | +</openerp> |
Hi, Alexis, thanks for your work. This module can be very appreciated. We are trying to increase the quality and standarization on community modules, so let me make some suggestions on your code:
- Put "from . import xxx" instead of "import xxx" in __init__.py file.
- Instantiate orm.Model instead osv.Model.
- Be PEP8 compatible. You can use flake8 tool to check this.
I'll do a functional test later.
Thank you again.
Regards.