Merge lp:~elbati/account-payment/adding_account_voucher_supplier_invoice_number_7 into lp:~account-payment-team/account-payment/7.0

Proposed by Lorenzo Battistini
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
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Stefan Rijnhart (Opener) Approve
Review via email: mp+165622@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) 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?

Nit: l.2866 could be kept at < 80 chars

review: Needs Information
100. By Lorenzo Battistini

[fix] line length

Revision history for this message
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

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

Thanks! In that case, it would probably be best if the tests were removed.

review: Needs Fixing
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

Revision history for this message
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_invoice_number field) the supplier
payment one.

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

Thanks!

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

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'account_voucher_supplier_invoice_number'
=== added file 'account_voucher_supplier_invoice_number/AUTHORS.txt'
--- account_voucher_supplier_invoice_number/AUTHORS.txt 1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/AUTHORS.txt 2013-05-31 08:44:26 +0000
@@ -0,0 +1,1 @@
1Lorenzo Battistini <lorenzo.battistini@agilebg.com>
02
=== added file 'account_voucher_supplier_invoice_number/__init__.py'
--- account_voucher_supplier_invoice_number/__init__.py 1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/__init__.py 2013-05-31 08:44:26 +0000
@@ -0,0 +1,22 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2013 Agile Business Group sagl
5# (<http://www.agilebg.com>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published
9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import voucher
023
=== added file 'account_voucher_supplier_invoice_number/__openerp__.py'
--- account_voucher_supplier_invoice_number/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/__openerp__.py 2013-05-31 08:44:26 +0000
@@ -0,0 +1,42 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2013 Agile Business Group sagl
5# (<http://www.agilebg.com>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published
9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22{
23 'name': "Supplier invoice number in payment vouchers",
24 'version': '0.1',
25 'category': 'Accounting & Finance',
26 'description': """
27This 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.
28""",
29 'author': 'Agile Business Group',
30 'website': 'http://www.agilebg.com',
31 'license': 'AGPL-3',
32 "depends" : ['account_voucher'],
33 "data" : [
34 'voucher_view.xml',
35 ],
36 'test' : [
37 'test/purchase_payment.yml',
38 ],
39 "demo" : [],
40 "active": False,
41 "installable": True
42}
043
=== added directory 'account_voucher_supplier_invoice_number/test'
=== added file 'account_voucher_supplier_invoice_number/test/purchase_payment.yml'
--- account_voucher_supplier_invoice_number/test/purchase_payment.yml 1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/test/purchase_payment.yml 2013-05-31 08:44:26 +0000
@@ -0,0 +1,63 @@
1-
2 Create an invoice for the partner Seagate with amount 450.0
3-
4 !python {model: account.invoice}: |
5 context.update({'type': 'in_invoice'})
6-
7 !record {model: account.invoice, id: account_invoice_0}:
8 account_id: account.a_pay
9 company_id: base.main_company
10 currency_id: base.EUR
11 supplier_invoice_number: '2013/003864'
12 invoice_line:
13 - account_id: account.a_expense
14 name: '[PCSC234] PC Assemble SC234'
15 price_unit: 450.0
16 quantity: 1.0
17 product_id: product.product_product_3
18 uos_id: product.product_uom_unit
19 journal_id: account.expenses_journal
20 partner_id: base.res_partner_19
21
22-
23 I check that the invoice is in draft state
24-
25 !assert {model: account.invoice, id: account_invoice_0}:
26 - state == 'draft'
27
28-
29 I make the invoice in Open state
30-
31 !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_0}
32
33-
34 I will create and post an account voucher of amount 450.0 for the partner Seagate.
35-
36 !python {model: account.voucher}: |
37 import netsvc
38 vals = {}
39 res = self.onchange_partner_id(cr, uid, [], ref("base.res_partner_19"), ref('account.bank_journal'), 0.0, 1, ttype='payment', date=False)
40 vals = {
41 'account_id': ref('account.cash'),
42 'amount': 450.0,
43 'company_id': ref('base.main_company'),
44 'journal_id': ref('account.bank_journal'),
45 'partner_id': ref('base.res_partner_19'),
46 'period_id': ref('account.period_8'),
47 'type': 'payment',
48 }
49 if not res['value']['line_dr_ids']:
50 res['value']['line_dr_ids'] = [{'type': 'dr', 'account_id': ref('account.a_pay'),}]
51 res['value']['line_dr_ids'][0]['amount'] = 450.0
52 vals['line_dr_ids'] = [(0,0,i) for i in res['value']['line_dr_ids']]
53 id = self.create(cr, uid, vals)
54 voucher = self.browse(cr, uid, id)
55 assert (voucher.state=='draft'), "Voucher is not in draft state"
56 wf_service = netsvc.LocalService("workflow")
57 wf_service.trg_validate(uid, 'account.voucher', voucher.id, 'proforma_voucher', cr)
58 assert (voucher.line_ids[0].supplier_invoice_number == '2013/003864'), 'wrong supplier_invoice_number'
59-
60 Finally i will Confirm the state of the invoice is paid
61-
62 !assert {model: account.invoice, id: account_invoice_0}:
63 - state == 'paid'
064
=== added file 'account_voucher_supplier_invoice_number/voucher.py'
--- account_voucher_supplier_invoice_number/voucher.py 1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/voucher.py 2013-05-31 08:44:26 +0000
@@ -0,0 +1,65 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2013 Agile Business Group sagl
5# (<http://www.agilebg.com>)
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published
9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openerp.osv import fields, orm
23from tools.translate import _
24
25class voucher_line(orm.Model):
26 _inherit = 'account.voucher.line'
27
28 def get_suppl_inv_num(self, cr, uid, move_line_id, context=None):
29 move_line = self.pool.get('account.move.line').browse(cr, uid, move_line_id, context)
30 return (move_line.invoice and move_line.invoice.supplier_invoice_number or '')
31
32 def _get_supplier_invoice_number(self, cr, uid, ids, name, args, context=None):
33 res={}
34 for line in self.browse(cr, uid, ids, context):
35 res[line.id] = ''
36 if line.move_line_id:
37 res[line.id] = self.get_suppl_inv_num(cr, uid,
38 line.move_line_id.id, context=context)
39 return res
40
41 _columns = {
42 'supplier_invoice_number': fields.function(_get_supplier_invoice_number,
43 type='char', size=64, string="Supplier Invoice Number"),
44 }
45
46class voucher(orm.Model):
47 _inherit = 'account.voucher'
48
49 def recompute_voucher_lines(self, cr, uid, ids, partner_id, journal_id, price,
50 currency_id, ttype, date, context=None):
51 res = super(voucher,self).recompute_voucher_lines(cr, uid, ids, partner_id,
52 journal_id, price,
53 currency_id, ttype, date, context=context)
54 line_obj = self.pool.get('account.voucher.line')
55 if res.get('value') and res['value'].get('line_cr_ids'):
56 for vals in res['value']['line_cr_ids']:
57 if vals.get('move_line_id'):
58 vals['supplier_invoice_number'] = line_obj.get_suppl_inv_num(
59 cr, uid, vals['move_line_id'], context=context)
60 if res.get('value') and res['value'].get('line_dr_ids'):
61 for vals in res['value']['line_dr_ids']:
62 if vals.get('move_line_id'):
63 vals['supplier_invoice_number'] = line_obj.get_suppl_inv_num(
64 cr, uid, vals['move_line_id'], context=context)
65 return res
066
=== added file 'account_voucher_supplier_invoice_number/voucher_view.xml'
--- account_voucher_supplier_invoice_number/voucher_view.xml 1970-01-01 00:00:00 +0000
+++ account_voucher_supplier_invoice_number/voucher_view.xml 2013-05-31 08:44:26 +0000
@@ -0,0 +1,20 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3<data>
4
5 <!-- Supplier Payment -->
6 <record model="ir.ui.view" id="view_vendor_payment_form">
7 <field name="name">account.voucher.payment.form</field>
8 <field name="model">account.voucher</field>
9 <field name="inherit_id" ref="account_voucher.view_vendor_payment_form"></field>
10 <field name="arch" type="xml">
11 <xpath expr="/form/sheet/notebook/page/field[@name='line_dr_ids']/tree/field[@name='move_line_id']" position="after">
12 <field name="supplier_invoice_number" />
13 </xpath>
14 <xpath expr="/form/sheet/notebook/page/field[@name='line_cr_ids']/tree/field[@name='move_line_id']" position="after">
15 <field name="supplier_invoice_number" />
16 </xpath>
17 </field>
18 </record>
19 </data>
20</openerp>