Merge lp:~vauxoo/addons-vauxoo/validate_type_line_invoice_dev_luis into lp:addons-vauxoo

Proposed by Luis Torres - http://www.vauxoo.com
Status: Merged
Merged at revision: 485
Proposed branch: lp:~vauxoo/addons-vauxoo/validate_type_line_invoice_dev_luis
Merge into: lp:addons-vauxoo
Diff against target: 136 lines (+121/-0)
3 files modified
validate_type_line_invoice/__init__.py (+26/-0)
validate_type_line_invoice/__openerp__.py (+46/-0)
validate_type_line_invoice/account_invoice.py (+49/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/validate_type_line_invoice_dev_luis
Reviewer Review Type Date Requested Status
Luis Torres - http://www.vauxoo.com Needs Resubmitting
Rodolfo Lopez (community) Needs Fixing
Moisés López - http://www.vauxoo.com Pending
Isaac López Zúñiga Pending
Review via email: mp+124524@code.launchpad.net

Description of the change

Se agrego una validacion para que al momento de validar la factura revise que el tipo de cuenta de las lineas sea diferente a 'payable' o receivable'

To post a comment you must log in.
Revision history for this message
Moisés López - http://www.vauxoo.com (moylop260) wrote :

Luis,
Tienes que regresar lo mismo que regresaría la original.
Y si llegara a entrar al raise te darás cuenta, que ya no frena todo lo que estaba haciendo la función, y hace rollback de lo demás.

Mira, aquí te mando un cambio de lógica de esto que te comento.

119 + def action_move_create(self, cr, uid, ids, context=None):
120 + invoice_line_obj=self.pool.get('account.invoice.line')
121 + account_obj=self.pool.get('account.account')
122 + lines = invoice_line_obj.search(cr,uid,[('invoice_id','=',ids)])
123 + ban=0
124 + for line in lines:
125 + id_account=invoice_line_obj.browse(cr,uid,line).account_id.id
126 + type_line=account_obj.browse(cr,uid,id_account).type
127 + if type_line == 'receivable' or type_line == 'payable':
132 + raise osv.except_osv(_('Error'), _("Type of account in line's most be differt to
133 + return super(account_invoice, self).action_move_create(cr, uid, ids)

Revision history for this message
Rodolfo Lopez (el-rodo-1) wrote :

Generar una validación mas:
si la factura es de cliente (out_invoice,out_refound) validar que la cuenta de la factura sea "a cobrar".
y si la factura es de proveedor (in_invoice, in_refound) validar que la cuenta de la factura sea "a pagar".
tienen domain para asegurarse que no la puedan elegir mal, pero no valida que no le puedan cambiar, por esto debe validar también en el botón validar que sea del tipo correspondiente:

review: Needs Fixing
447. By Luis Torres - http://www.vauxoo.com

[IMP]Validate that type account invoice for customer was 'receivable' & to partner was 'payable'

Revision history for this message
Luis Torres - http://www.vauxoo.com (luis-cleto-) wrote :

Se valida que:
si la factura es de cliente (out_invoice,out_refound) validar que la cuenta de la factura sea "a cobrar".
y si la factura es de proveedor (in_invoice, in_refound) validar que la cuenta de la factura sea "a pagar".

review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'validate_type_line_invoice'
2=== added file 'validate_type_line_invoice/__init__.py'
3--- validate_type_line_invoice/__init__.py 1970-01-01 00:00:00 +0000
4+++ validate_type_line_invoice/__init__.py 2012-09-18 21:03:19 +0000
5@@ -0,0 +1,26 @@
6+# -*- encoding: utf-8 -*-
7+###########################################################################
8+# Module Writen to OpenERP, Open Source Management Solution
9+#
10+# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
11+# All Rights Reserved.
12+# info Vauxoo (info@vauxoo.com)
13+############################################################################
14+# Coded by: Luis Torres (luis_t@vauxoo.com)
15+############################################################################
16+#
17+# This program is free software: you can redistribute it and/or modify
18+# it under the terms of the GNU Affero General Public License as
19+# published by the Free Software Foundation, either version 3 of the
20+# License, or (at your option) any later version.
21+#
22+# This program is distributed in the hope that it will be useful,
23+# but WITHOUT ANY WARRANTY; without even the implied warranty of
24+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+# GNU Affero General Public License for more details.
26+#
27+# You should have received a copy of the GNU Affero General Public License
28+# along with this program. If not, see <http://www.gnu.org/licenses/>.
29+#
30+##############################################################################
31+import account_invoice
32
33=== added file 'validate_type_line_invoice/__openerp__.py'
34--- validate_type_line_invoice/__openerp__.py 1970-01-01 00:00:00 +0000
35+++ validate_type_line_invoice/__openerp__.py 2012-09-18 21:03:19 +0000
36@@ -0,0 +1,46 @@
37+# -*- encoding: utf-8 -*-
38+###########################################################################
39+# Module Writen to OpenERP, Open Source Management Solution
40+#
41+# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
42+# All Rights Reserved.
43+# info Vauxoo (info@vauxoo.com)
44+############################################################################
45+# Coded by: Luis Torres (luis_t@vauxoo.com)
46+############################################################################
47+#
48+# This program is free software: you can redistribute it and/or modify
49+# it under the terms of the GNU Affero General Public License as
50+# published by the Free Software Foundation, either version 3 of the
51+# License, or (at your option) any later version.
52+#
53+# This program is distributed in the hope that it will be useful,
54+# but WITHOUT ANY WARRANTY; without even the implied warranty of
55+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56+# GNU Affero General Public License for more details.
57+#
58+# You should have received a copy of the GNU Affero General Public License
59+# along with this program. If not, see <http://www.gnu.org/licenses/>.
60+#
61+##############################################################################
62+
63+{
64+ "name" : "Validate Type Line Invoice",
65+ "version" : "1.0",
66+ "author" : "Vauxoo",
67+ "category" : "Generic Modules",
68+ "description" : """
69+ This module validate that type line to invoice is different to "a pagar" or "a cobrar"
70+ """,
71+ "website" : "http://www.vauxoo.com/",
72+ "license" : "AGPL-3",
73+ "depends" : ["account",
74+ ],
75+ "init_xml" : [],
76+ "demo_xml" : [],
77+ "update_xml" : [
78+
79+ ],
80+ "installable" : True,
81+ "active" : False,
82+}
83
84=== added file 'validate_type_line_invoice/account_invoice.py'
85--- validate_type_line_invoice/account_invoice.py 1970-01-01 00:00:00 +0000
86+++ validate_type_line_invoice/account_invoice.py 2012-09-18 21:03:19 +0000
87@@ -0,0 +1,49 @@
88+# -*- encoding: utf-8 -*-
89+###########################################################################
90+# Module Writen to OpenERP, Open Source Management Solution
91+#
92+# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
93+# All Rights Reserved.
94+# info Vauxoo (info@vauxoo.com)
95+############################################################################
96+# Coded by: Luis Torres (luis_t@vauxoo.com)
97+############################################################################
98+#
99+# This program is free software: you can redistribute it and/or modify
100+# it under the terms of the GNU Affero General Public License as
101+# published by the Free Software Foundation, either version 3 of the
102+# License, or (at your option) any later version.
103+#
104+# This program is distributed in the hope that it will be useful,
105+# but WITHOUT ANY WARRANTY; without even the implied warranty of
106+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
107+# GNU Affero General Public License for more details.
108+#
109+# You should have received a copy of the GNU Affero General Public License
110+# along with this program. If not, see <http://www.gnu.org/licenses/>.
111+#
112+##############################################################################
113+from osv import osv, fields
114+from tools.translate import _
115+
116+class account_invoice(osv.osv):
117+ _inherit = 'account.invoice'
118+
119+ def action_move_create(self, cr, uid, ids, context=None):
120+ invoice_line_obj=self.pool.get('account.invoice.line')
121+ account_obj=self.pool.get('account.account')
122+ for id_ in ids:
123+ lines = invoice_line_obj.search(cr,uid,[('invoice_id','=',id_)])
124+ for line in lines:
125+ id_account=invoice_line_obj.browse(cr,uid,line).account_id.id
126+ type_line=account_obj.browse(cr,uid,id_account).type
127+ if type_line == 'receivable' or type_line == 'payable':
128+ raise osv.except_osv(_('Error'), _("Type of account in line's must be differt to 'receivable' and 'payable'"))
129+ type_acc_invo=self.browse(cr,uid,id_).account_id.type
130+ type_invoice=self.browse(cr,uid,id_).type
131+ if (type_invoice == 'out_invoice' or type_invoice=='out_refound') and type_acc_invo != 'receivable':
132+ raise osv.except_osv(_('Error'), _("Type of account in invoice to Customer must be 'receivable'"))
133+ if (type_invoice == 'in_invoice' or type_invoice=='in_refound') and type_acc_invo != 'payable':
134+ raise osv.except_osv(_('Error'), _("Type of account in invoice to Partner must be 'payable'"))
135+ return super(account_invoice, self).action_move_create(cr, uid, ids)
136+account_invoice()