Merge lp:~elbati/account-payment/adding_account_voucher_supplier_invoice_number_7 into lp:~account-payment-team/account-payment/7.0
- adding_account_voucher_supplier_invoice_number_7
- Merge into 7.0
Status: | Merged |
---|---|
Merged at revision: | 99 |
Proposed branch: | lp:~elbati/account-payment/adding_account_voucher_supplier_invoice_number_7 |
Merge into: | lp:~account-payment-team/account-payment/7.0 |
Diff against target: |
244 lines (+213/-0) 6 files modified
account_voucher_supplier_invoice_number/AUTHORS.txt (+1/-0) account_voucher_supplier_invoice_number/__init__.py (+22/-0) account_voucher_supplier_invoice_number/__openerp__.py (+42/-0) account_voucher_supplier_invoice_number/test/purchase_payment.yml (+63/-0) account_voucher_supplier_invoice_number/voucher.py (+65/-0) account_voucher_supplier_invoice_number/voucher_view.xml (+20/-0) |
To merge this branch: | bzr merge lp:~elbati/account-payment/adding_account_voucher_supplier_invoice_number_7 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guewen Baconnier @ Camptocamp | Approve | ||
Stefan Rijnhart (Opener) | Approve | ||
Review via email: mp+165622@code.launchpad.net |
Commit message
Description of the change
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
- 100. By Lorenzo Battistini
-
[fix] line length
Lorenzo Battistini (elbati) wrote : | # |
On 05/24/2013 07:12 PM, Stefan Rijnhart (Therp) wrote:
> Looks good, functionally. I am just wondering, why did you include the whole test suite of the voucher module, given that this module hardly influences any calculation or move line creation?
To be sure this module does not influence any calculation or move line
creation :-)
Anyway, I can remove some of them, if unnecessary.
> Nit: l.2866 could be kept at < 80 chars
>
Done
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
Thanks! In that case, it would probably be best if the tests were removed.
- 101. By Lorenzo Battistini
-
[del] useless tests
- 102. By Lorenzo Battistini
-
[add] not working purchase voucher
- 103. By Lorenzo Battistini
-
[fix] supplier invoice creation test
- 104. By Lorenzo Battistini
-
[imp] test checking supplier_
invoice_ number
Lorenzo Battistini (elbati) wrote : | # |
On 05/26/2013 07:39 PM, Stefan Rijnhart (Therp) wrote:
> Thanks! In that case, it would probably be best if the tests were removed.
Removed.
I kept and improved (testing supplier_
payment one.
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
Thanks!
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
LGTM
Preview Diff
1 | === added directory 'account_voucher_supplier_invoice_number' |
2 | === added file 'account_voucher_supplier_invoice_number/AUTHORS.txt' |
3 | --- account_voucher_supplier_invoice_number/AUTHORS.txt 1970-01-01 00:00:00 +0000 |
4 | +++ account_voucher_supplier_invoice_number/AUTHORS.txt 2013-05-31 08:44:26 +0000 |
5 | @@ -0,0 +1,1 @@ |
6 | +Lorenzo Battistini <lorenzo.battistini@agilebg.com> |
7 | |
8 | === added file 'account_voucher_supplier_invoice_number/__init__.py' |
9 | --- account_voucher_supplier_invoice_number/__init__.py 1970-01-01 00:00:00 +0000 |
10 | +++ account_voucher_supplier_invoice_number/__init__.py 2013-05-31 08:44:26 +0000 |
11 | @@ -0,0 +1,22 @@ |
12 | +# -*- coding: utf-8 -*- |
13 | +############################################################################## |
14 | +# |
15 | +# Copyright (C) 2013 Agile Business Group sagl |
16 | +# (<http://www.agilebg.com>) |
17 | +# |
18 | +# This program is free software: you can redistribute it and/or modify |
19 | +# it under the terms of the GNU Affero General Public License as published |
20 | +# by the Free Software Foundation, either version 3 of the License, or |
21 | +# (at your option) any later version. |
22 | +# |
23 | +# This program is distributed in the hope that it will be useful, |
24 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
25 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
26 | +# GNU Affero General Public License for more details. |
27 | +# |
28 | +# You should have received a copy of the GNU Affero General Public License |
29 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
30 | +# |
31 | +############################################################################## |
32 | + |
33 | +import voucher |
34 | |
35 | === added file 'account_voucher_supplier_invoice_number/__openerp__.py' |
36 | --- account_voucher_supplier_invoice_number/__openerp__.py 1970-01-01 00:00:00 +0000 |
37 | +++ account_voucher_supplier_invoice_number/__openerp__.py 2013-05-31 08:44:26 +0000 |
38 | @@ -0,0 +1,42 @@ |
39 | +# -*- coding: utf-8 -*- |
40 | +############################################################################## |
41 | +# |
42 | +# Copyright (C) 2013 Agile Business Group sagl |
43 | +# (<http://www.agilebg.com>) |
44 | +# |
45 | +# This program is free software: you can redistribute it and/or modify |
46 | +# it under the terms of the GNU Affero General Public License as published |
47 | +# by the Free Software Foundation, either version 3 of the License, or |
48 | +# (at your option) any later version. |
49 | +# |
50 | +# This program is distributed in the hope that it will be useful, |
51 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
52 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
53 | +# GNU Affero General Public License for more details. |
54 | +# |
55 | +# You should have received a copy of the GNU Affero General Public License |
56 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
57 | +# |
58 | +############################################################################## |
59 | + |
60 | +{ |
61 | + 'name': "Supplier invoice number in payment vouchers", |
62 | + 'version': '0.1', |
63 | + 'category': 'Accounting & Finance', |
64 | + 'description': """ |
65 | +This module adds the supplier invoice number to (Supplier Payment) voucher lines. So that it's more easy to find the right invoice we are going to pay. |
66 | +""", |
67 | + 'author': 'Agile Business Group', |
68 | + 'website': 'http://www.agilebg.com', |
69 | + 'license': 'AGPL-3', |
70 | + "depends" : ['account_voucher'], |
71 | + "data" : [ |
72 | + 'voucher_view.xml', |
73 | + ], |
74 | + 'test' : [ |
75 | + 'test/purchase_payment.yml', |
76 | + ], |
77 | + "demo" : [], |
78 | + "active": False, |
79 | + "installable": True |
80 | +} |
81 | |
82 | === added directory 'account_voucher_supplier_invoice_number/test' |
83 | === added file 'account_voucher_supplier_invoice_number/test/purchase_payment.yml' |
84 | --- account_voucher_supplier_invoice_number/test/purchase_payment.yml 1970-01-01 00:00:00 +0000 |
85 | +++ account_voucher_supplier_invoice_number/test/purchase_payment.yml 2013-05-31 08:44:26 +0000 |
86 | @@ -0,0 +1,63 @@ |
87 | +- |
88 | + Create an invoice for the partner Seagate with amount 450.0 |
89 | +- |
90 | + !python {model: account.invoice}: | |
91 | + context.update({'type': 'in_invoice'}) |
92 | +- |
93 | + !record {model: account.invoice, id: account_invoice_0}: |
94 | + account_id: account.a_pay |
95 | + company_id: base.main_company |
96 | + currency_id: base.EUR |
97 | + supplier_invoice_number: '2013/003864' |
98 | + invoice_line: |
99 | + - account_id: account.a_expense |
100 | + name: '[PCSC234] PC Assemble SC234' |
101 | + price_unit: 450.0 |
102 | + quantity: 1.0 |
103 | + product_id: product.product_product_3 |
104 | + uos_id: product.product_uom_unit |
105 | + journal_id: account.expenses_journal |
106 | + partner_id: base.res_partner_19 |
107 | + |
108 | +- |
109 | + I check that the invoice is in draft state |
110 | +- |
111 | + !assert {model: account.invoice, id: account_invoice_0}: |
112 | + - state == 'draft' |
113 | + |
114 | +- |
115 | + I make the invoice in Open state |
116 | +- |
117 | + !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_0} |
118 | + |
119 | +- |
120 | + I will create and post an account voucher of amount 450.0 for the partner Seagate. |
121 | +- |
122 | + !python {model: account.voucher}: | |
123 | + import netsvc |
124 | + vals = {} |
125 | + res = self.onchange_partner_id(cr, uid, [], ref("base.res_partner_19"), ref('account.bank_journal'), 0.0, 1, ttype='payment', date=False) |
126 | + vals = { |
127 | + 'account_id': ref('account.cash'), |
128 | + 'amount': 450.0, |
129 | + 'company_id': ref('base.main_company'), |
130 | + 'journal_id': ref('account.bank_journal'), |
131 | + 'partner_id': ref('base.res_partner_19'), |
132 | + 'period_id': ref('account.period_8'), |
133 | + 'type': 'payment', |
134 | + } |
135 | + if not res['value']['line_dr_ids']: |
136 | + res['value']['line_dr_ids'] = [{'type': 'dr', 'account_id': ref('account.a_pay'),}] |
137 | + res['value']['line_dr_ids'][0]['amount'] = 450.0 |
138 | + vals['line_dr_ids'] = [(0,0,i) for i in res['value']['line_dr_ids']] |
139 | + id = self.create(cr, uid, vals) |
140 | + voucher = self.browse(cr, uid, id) |
141 | + assert (voucher.state=='draft'), "Voucher is not in draft state" |
142 | + wf_service = netsvc.LocalService("workflow") |
143 | + wf_service.trg_validate(uid, 'account.voucher', voucher.id, 'proforma_voucher', cr) |
144 | + assert (voucher.line_ids[0].supplier_invoice_number == '2013/003864'), 'wrong supplier_invoice_number' |
145 | +- |
146 | + Finally i will Confirm the state of the invoice is paid |
147 | +- |
148 | + !assert {model: account.invoice, id: account_invoice_0}: |
149 | + - state == 'paid' |
150 | |
151 | === added file 'account_voucher_supplier_invoice_number/voucher.py' |
152 | --- account_voucher_supplier_invoice_number/voucher.py 1970-01-01 00:00:00 +0000 |
153 | +++ account_voucher_supplier_invoice_number/voucher.py 2013-05-31 08:44:26 +0000 |
154 | @@ -0,0 +1,65 @@ |
155 | +# -*- coding: utf-8 -*- |
156 | +############################################################################## |
157 | +# |
158 | +# Copyright (C) 2013 Agile Business Group sagl |
159 | +# (<http://www.agilebg.com>) |
160 | +# |
161 | +# This program is free software: you can redistribute it and/or modify |
162 | +# it under the terms of the GNU Affero General Public License as published |
163 | +# by the Free Software Foundation, either version 3 of the License, or |
164 | +# (at your option) any later version. |
165 | +# |
166 | +# This program is distributed in the hope that it will be useful, |
167 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
168 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
169 | +# GNU Affero General Public License for more details. |
170 | +# |
171 | +# You should have received a copy of the GNU Affero General Public License |
172 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
173 | +# |
174 | +############################################################################## |
175 | + |
176 | +from openerp.osv import fields, orm |
177 | +from tools.translate import _ |
178 | + |
179 | +class voucher_line(orm.Model): |
180 | + _inherit = 'account.voucher.line' |
181 | + |
182 | + def get_suppl_inv_num(self, cr, uid, move_line_id, context=None): |
183 | + move_line = self.pool.get('account.move.line').browse(cr, uid, move_line_id, context) |
184 | + return (move_line.invoice and move_line.invoice.supplier_invoice_number or '') |
185 | + |
186 | + def _get_supplier_invoice_number(self, cr, uid, ids, name, args, context=None): |
187 | + res={} |
188 | + for line in self.browse(cr, uid, ids, context): |
189 | + res[line.id] = '' |
190 | + if line.move_line_id: |
191 | + res[line.id] = self.get_suppl_inv_num(cr, uid, |
192 | + line.move_line_id.id, context=context) |
193 | + return res |
194 | + |
195 | + _columns = { |
196 | + 'supplier_invoice_number': fields.function(_get_supplier_invoice_number, |
197 | + type='char', size=64, string="Supplier Invoice Number"), |
198 | + } |
199 | + |
200 | +class voucher(orm.Model): |
201 | + _inherit = 'account.voucher' |
202 | + |
203 | + def recompute_voucher_lines(self, cr, uid, ids, partner_id, journal_id, price, |
204 | + currency_id, ttype, date, context=None): |
205 | + res = super(voucher,self).recompute_voucher_lines(cr, uid, ids, partner_id, |
206 | + journal_id, price, |
207 | + currency_id, ttype, date, context=context) |
208 | + line_obj = self.pool.get('account.voucher.line') |
209 | + if res.get('value') and res['value'].get('line_cr_ids'): |
210 | + for vals in res['value']['line_cr_ids']: |
211 | + if vals.get('move_line_id'): |
212 | + vals['supplier_invoice_number'] = line_obj.get_suppl_inv_num( |
213 | + cr, uid, vals['move_line_id'], context=context) |
214 | + if res.get('value') and res['value'].get('line_dr_ids'): |
215 | + for vals in res['value']['line_dr_ids']: |
216 | + if vals.get('move_line_id'): |
217 | + vals['supplier_invoice_number'] = line_obj.get_suppl_inv_num( |
218 | + cr, uid, vals['move_line_id'], context=context) |
219 | + return res |
220 | |
221 | === added file 'account_voucher_supplier_invoice_number/voucher_view.xml' |
222 | --- account_voucher_supplier_invoice_number/voucher_view.xml 1970-01-01 00:00:00 +0000 |
223 | +++ account_voucher_supplier_invoice_number/voucher_view.xml 2013-05-31 08:44:26 +0000 |
224 | @@ -0,0 +1,20 @@ |
225 | +<?xml version="1.0" encoding="utf-8"?> |
226 | +<openerp> |
227 | +<data> |
228 | + |
229 | + <!-- Supplier Payment --> |
230 | + <record model="ir.ui.view" id="view_vendor_payment_form"> |
231 | + <field name="name">account.voucher.payment.form</field> |
232 | + <field name="model">account.voucher</field> |
233 | + <field name="inherit_id" ref="account_voucher.view_vendor_payment_form"></field> |
234 | + <field name="arch" type="xml"> |
235 | + <xpath expr="/form/sheet/notebook/page/field[@name='line_dr_ids']/tree/field[@name='move_line_id']" position="after"> |
236 | + <field name="supplier_invoice_number" /> |
237 | + </xpath> |
238 | + <xpath expr="/form/sheet/notebook/page/field[@name='line_cr_ids']/tree/field[@name='move_line_id']" position="after"> |
239 | + <field name="supplier_invoice_number" /> |
240 | + </xpath> |
241 | + </field> |
242 | + </record> |
243 | + </data> |
244 | +</openerp> |
Looks good, functionally. I am just wondering, why did you include the whole test suite of the voucher module, given that this module hardly influences any calculation or move line creation?
Nit: l.2866 could be kept at < 80 chars