Merge lp:~jean-lelievre/account-payment/account_prepayment into lp:~account-payment-team/account-payment/6.1

Proposed by Jean LELIEVRE ElicoCorp
Status: Work in progress
Proposed branch: lp:~jean-lelievre/account-payment/account_prepayment
Merge into: lp:~account-payment-team/account-payment/6.1
Diff against target: 356 lines (+328/-0)
5 files modified
account_prepayment/__init__.py (+25/-0)
account_prepayment/__openerp__.py (+50/-0)
account_prepayment/account.py (+107/-0)
account_prepayment/account_view.xml (+65/-0)
account_prepayment/i18n/zh_CN.po (+81/-0)
To merge this branch: bzr merge lp:~jean-lelievre/account-payment/account_prepayment
Reviewer Review Type Date Requested Status
Maxime Chambreuil (http://www.savoirfairelinux.com) code review Needs Fixing
Account Payment Pending
Review via email: mp+182021@code.launchpad.net

Description of the change

[ADD] Add the module account_prepayment

Prepayment Module For Opentrading
==================================================
Fine tune Prepayment addon \n
* Add Prepayment Account In Partner \n
* Add purchase_order_id and Prepayment Account in payment.

To post a comment you must log in.
Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) wrote :

Hello Jean,

l117: you need an extra line to be PEP8 compliant. Running flake8 on your module will help you with that.

You made the translation in chinese but the pot file for other translations is missing.

Otherwise LGTM.

Thanks!

review: Needs Fixing (code review)
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

No changes since 2013-11-10 after Need Fixing request -> I set this in WIP

@Jean LELIEVRE

Please do the required changes then set it in Needs Review again

Cheers,
Yannick

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

This project is now hosted on https://github.com/OCA/account-payment. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

Unmerged revisions

105. By Jean LELIEVRE ElicoCorp

[ADD] Add the module 'account_prepayment'

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_prepayment'
2=== added file 'account_prepayment/__init__.py'
3--- account_prepayment/__init__.py 1970-01-01 00:00:00 +0000
4+++ account_prepayment/__init__.py 2013-08-26 03:48:18 +0000
5@@ -0,0 +1,25 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# OpenERP, Open Source Management Solution
10+# Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
11+# Author: Andy Lu <andy.lu@elico-corp.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+import account
29+
30+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
31\ No newline at end of file
32
33=== added file 'account_prepayment/__openerp__.py'
34--- account_prepayment/__openerp__.py 1970-01-01 00:00:00 +0000
35+++ account_prepayment/__openerp__.py 2013-08-26 03:48:18 +0000
36@@ -0,0 +1,50 @@
37+# -*- coding: utf-8 -*-
38+##############################################################################
39+#
40+# OpenERP, Open Source Management Solution
41+# Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
42+# Author: Andy Lu <andy.lu@elico-corp.com>
43+#
44+# This program is free software: you can redistribute it and/or modify
45+# it under the terms of the GNU Affero General Public License as
46+# published by the Free Software Foundation, either version 3 of the
47+# License, or (at your option) any later version.
48+#
49+# This program is distributed in the hope that it will be useful,
50+# but WITHOUT ANY WARRANTY; without even the implied warranty of
51+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52+# GNU Affero General Public License for more details.
53+#
54+# You should have received a copy of the GNU Affero General Public License
55+# along with this program. If not, see <http://www.gnu.org/licenses/>.
56+#
57+##############################################################################
58+
59+{
60+ 'name': 'Prepayment',
61+ 'version': '1.0',
62+ 'category': 'Account',
63+ 'sequence': 20,
64+ 'summary': 'Account Prepayment',
65+ 'description': """
66+Prepayment Module For Opentrading
67+==================================================
68+Fine tune Prepayment addon \n
69+* Add Prepayment Account In Partner \n
70+* Add purchase_order_id and Prepayment Account in payment.
71+ """,
72+ 'author': 'Elico Corp',
73+ 'website': 'http://www.elico-corp.com',
74+ 'images' : [],
75+ 'depends': ['account', 'account_voucher', 'purchase'],
76+ 'data': [
77+ 'account_view.xml',
78+ ],
79+ 'test': [],
80+ 'demo': [],
81+ 'installable': True,
82+ 'auto_install': False,
83+ 'application': False,
84+}
85+
86+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
87\ No newline at end of file
88
89=== added file 'account_prepayment/account.py'
90--- account_prepayment/account.py 1970-01-01 00:00:00 +0000
91+++ account_prepayment/account.py 2013-08-26 03:48:18 +0000
92@@ -0,0 +1,107 @@
93+# -*- coding: utf-8 -*-
94+##############################################################################
95+#
96+# OpenERP, Open Source Management Solution
97+# Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
98+# Author: Andy Lu <andy.lu@elico-corp.com>
99+#
100+# This program is free software: you can redistribute it and/or modify
101+# it under the terms of the GNU Affero General Public License as
102+# published by the Free Software Foundation, either version 3 of the
103+# License, or (at your option) any later version.
104+#
105+# This program is distributed in the hope that it will be useful,
106+# but WITHOUT ANY WARRANTY; without even the implied warranty of
107+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
108+# GNU Affero General Public License for more details.
109+#
110+# You should have received a copy of the GNU Affero General Public License
111+# along with this program. If not, see <http://www.gnu.org/licenses/>.
112+#
113+##############################################################################
114+
115+from osv import osv, fields
116+from tools.translate import _
117+
118+class res_partner(osv.osv):
119+ _inherit = 'res.partner'
120+
121+ _columns = {
122+ 'property_account_prepayable': fields.property(
123+ 'account.account',
124+ type='many2one',
125+ relation='account.account',
126+ string="Account payable (Prepayment)",
127+ view_load=True,
128+ domain="[('type', '=', 'payable')]",
129+ help="This account will be used instead of the default one as the Prepayment payable account for the current partner",
130+ required=True),
131+ 'property_account_prereceivable': fields.property(
132+ 'account.account',
133+ type='many2one',
134+ relation='account.account',
135+ string="Account Receivable (Prepayment)",
136+ view_load=True,
137+ domain="[('type', '=', 'receivable')]",
138+ help="This account will be used instead of the default one as the Prepayment receivable account for the current partner",
139+ required=True),
140+ }
141+
142+class account_voucher(osv.osv):
143+ _inherit = "account.voucher"
144+
145+ _columns = {
146+ 'purchase_id': fields.many2one('purchase.order', 'Purchase Order', domain=[('invoiced','=', False)], ondelete='set null'),
147+ 'use_prepayment_account': fields.boolean('Use Prepayment account', help="Check this if you want to input a prepayment on the prepayment accounts."),
148+ }
149+ _defaults = {
150+ 'use_prepayment_account': False,
151+ }
152+
153+ def onchange_purchase_id(self, cr, uid, ids, purchase_id):
154+ res = {}
155+ if not purchase_id:
156+ return res
157+
158+ amount = 0
159+ po_obj = self.pool.get('purchase.order')
160+ po = po_obj.browse(cr, uid, purchase_id)
161+ if po.invoiced:
162+ res['warning'] = {'title': _('Warning!'), 'message': _('Selected Purchase Order was paid.')}
163+ for invoice in po.invoice_ids:
164+ if invoice.state in ('paid'):
165+ amount += invoice.amount_total
166+ res['value'] = {'partner_id': po.partner_id.id, 'amount': po.amount_total - amount}
167+ return res
168+
169+ def onchange_prepayment_account(self, cr, uid, ids, use_prepayment_account):
170+ res = {}
171+ if not use_prepayment_account:
172+ return res
173+
174+ res['value'] = {'line_cr_ids': [],'line_dr_ids': [],'line_ids': []}
175+ return res
176+
177+ def writeoff_move_line_get(self, cr, uid, voucher_id, line_total, move_id, name, company_currency, current_currency, context=None):
178+ line_vals = super(account_voucher, self).writeoff_move_line_get(cr, uid, voucher_id, line_total, move_id, name, company_currency, current_currency, context=context)
179+ if line_vals:
180+ account_id = False
181+ voucher_brw = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context)
182+ if voucher_brw.use_prepayment_account:
183+ if voucher_brw.payment_option == 'with_writeoff':
184+ account_id = voucher_brw.writeoff_acc_id.id
185+ elif voucher_brw.type in ('sale', 'receipt'):
186+ if not voucher_brw.partner_id.property_account_prereceivable:
187+ raise osv.except_osv(_('Unable to validate payment !'), _('Please configure the partner Prereceivable Account at first!'))
188+ account_id = voucher_brw.partner_id.property_account_prereceivable.id
189+ else:
190+ if not voucher_brw.partner_id.property_account_prepayable:
191+ raise osv.except_osv(_('Unable to validate payment !'), _('Please configure the partner Prepayable Account at first!'))
192+ account_id = voucher_brw.partner_id.property_account_prepayable.id
193+ if account_id:
194+ line_vals['account_id'] = account_id
195+ return line_vals
196+account_voucher()
197+
198+
199+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
200
201=== added file 'account_prepayment/account_view.xml'
202--- account_prepayment/account_view.xml 1970-01-01 00:00:00 +0000
203+++ account_prepayment/account_view.xml 2013-08-26 03:48:18 +0000
204@@ -0,0 +1,65 @@
205+<?xml version="1.0" encoding="UTF-8"?>
206+<openerp>
207+ <data>
208+
209+ <!--
210+ Partners Extension
211+ -->
212+ <record id="view_partner_preaccount_property_form" model="ir.ui.view">
213+ <field name="name">res.partner.preaccount.property.form.inherit</field>
214+ <field name="model">res.partner</field>
215+ <field name="priority">3</field>
216+ <field name="inherit_id" ref="account.view_partner_property_form"/>
217+ <field name="arch" type="xml">
218+ <xpath expr="//field[@name='property_account_receivable']" position="after">
219+ <field name="property_account_prereceivable" groups="account.group_account_invoice" />
220+ </xpath>
221+ <xpath expr="//field[@name='property_account_payable']" position="after">
222+ <field name="property_account_prepayable" groups="account.group_account_invoice" />
223+ </xpath>
224+ </field>
225+ </record>
226+
227+ <record model="ir.ui.view" id="view_vendor_prepayment_form">
228+ <field name="name">account.voucher.prepayment.form</field>
229+ <field name="model">account.voucher</field>
230+ <field name="inherit_id" ref="account_voucher.view_vendor_payment_form" />
231+ <field name="arch" type="xml">
232+ <xpath expr="//field[@name='partner_id']" position="before">
233+ <field name="purchase_id" on_change="onchange_purchase_id(purchase_id)" />
234+ </xpath>
235+ <xpath expr="//field[@name='journal_id']" position="after">
236+ <field name="use_prepayment_account" on_change="onchange_prepayment_account(use_prepayment_account)"/>
237+ </xpath>
238+ </field>
239+ </record>
240+
241+ <record model="ir.ui.view" id="view_vendor_prereceipt_form">
242+ <field name="name">account.voucher.prereceipt.form</field>
243+ <field name="model">account.voucher</field>
244+ <field name="inherit_id" ref="account_voucher.view_vendor_receipt_form" />
245+ <field name="arch" type="xml">
246+ <xpath expr="//field[@name='journal_id']" position="after">
247+ <field name="use_prepayment_account"/>
248+ </xpath>
249+ </field>
250+ </record>
251+
252+ </data>
253+
254+ <!-- data noupdate="True">
255+ <record id="prepayable_account_property" model="ir.property">
256+ <field name="name">property_account_prepayable</field>
257+ <field name="fields_id" ref="fc_account_prepayment.field_res_partner_property_account_prepayable"/>
258+ <field name="company_id" ref="base.main_company"/>
259+ <field eval="'account.account,'+str(ref('l10n_cn.chart1123'))" model="account.account" name="value"/>
260+ </record>
261+ <record id="prereceivable_account_property" model="ir.property">
262+ <field name="name">property_account_prereceivable</field>
263+ <field name="fields_id" ref="fc_account_prepayment.field_res_partner_property_account_prereceivable"/>
264+ <field name="company_id" ref="base.main_company"/>
265+ <field eval="'account.account,'+str(ref('l10n_cn.chart2205'))" model="account.account" name="value"/>
266+ </record>
267+ </data -->
268+
269+</openerp>
270
271=== added directory 'account_prepayment/i18n'
272=== added file 'account_prepayment/i18n/zh_CN.po'
273--- account_prepayment/i18n/zh_CN.po 1970-01-01 00:00:00 +0000
274+++ account_prepayment/i18n/zh_CN.po 2013-08-26 03:48:18 +0000
275@@ -0,0 +1,81 @@
276+# Translation of OpenERP Server.
277+# This file contains the translation of the following modules:
278+# * fc_account_prepayment
279+#
280+msgid ""
281+msgstr ""
282+"Project-Id-Version: OpenERP Server 7.0alpha\n"
283+"Report-Msgid-Bugs-To: \n"
284+"POT-Creation-Date: 2013-03-13 06:33+0000\n"
285+"PO-Revision-Date: 2013-03-13 06:33+0000\n"
286+"Last-Translator: <>\n"
287+"Language-Team: \n"
288+"MIME-Version: 1.0\n"
289+"Content-Type: text/plain; charset=UTF-8\n"
290+"Content-Transfer-Encoding: \n"
291+"Plural-Forms: \n"
292+
293+#. module: fc_account_prepayment
294+#: field:res.partner,property_account_prepayable:0
295+msgid "Account Prepayable"
296+msgstr "预付科目"
297+
298+#. module: fc_account_prepayment
299+#: code:addons/fc_account_prepayment/account.py:70
300+#, python-format
301+msgid "Please configure the partner Prereceivable Account at first!"
302+msgstr "请先配置客户预收账款科目!"
303+
304+#. module: fc_account_prepayment
305+#: model:ir.model,name:fc_account_prepayment.model_account_voucher
306+msgid "Accounting Voucher"
307+msgstr "手工凭证"
308+
309+#. module: fc_account_prepayment
310+#: code:addons/fc_account_prepayment/account.py:74
311+#, python-format
312+msgid "Please configure the partner Prepayable Account at first!"
313+msgstr "请先配置供应商预付账款科目!"
314+
315+#. module: fc_account_prepayment
316+#: help:res.partner,property_account_prereceivable:0
317+msgid "This account will be used instead of the default one as the prereceivable account for the current partner"
318+msgstr "当前客户的预收账款科目"
319+
320+#. module: fc_account_prepayment
321+#: help:account.voucher,use_prepayment_account:0
322+msgid "Check this if you receive or pay amounts in advance."
323+msgstr "如果你要创建预收或者预付凭证,请选择此项."
324+
325+#. module: fc_account_prepayment
326+#: code:addons/fc_account_prepayment/account.py:70
327+#: code:addons/fc_account_prepayment/account.py:74
328+#, python-format
329+msgid "Unable to validate payment !"
330+msgstr "不能审核该笔支付 !"
331+
332+#. module: fc_account_prepayment
333+#: field:account.voucher,purchase_id:0
334+msgid "Use Prepayment account"
335+msgstr "采购订单"
336+
337+#. module: fc_account_prepayment
338+#: field:account.voucher,use_prepayment_account:0
339+msgid "Use Prepayment account"
340+msgstr "使用预付/预收科目"
341+
342+#. module: fc_account_prepayment
343+#: help:res.partner,property_account_prepayable:0
344+msgid "This account will be used instead of the default one as the prepayable account for the current partner"
345+msgstr "当前供应商的预付账款科目"
346+
347+#. module: fc_account_prepayment
348+#: model:ir.model,name:fc_account_prepayment.model_res_partner
349+msgid "Partner"
350+msgstr "业务伙伴"
351+
352+#. module: fc_account_prepayment
353+#: field:res.partner,property_account_prereceivable:0
354+msgid "Account Prereceivable"
355+msgstr "预收科目"
356+

Subscribers

People subscribed via source and target branches