← Back to team overview

account-payment-team team mailing list archive

[Merge] lp:~jean-lelievre/account-payment/account_prepayment into lp:account-payment

 

You have been requested to review the proposed merge of lp:~jean-lelievre/account-payment/account_prepayment into lp:account-payment.

For more details, see:
https://code.launchpad.net/~jean-lelievre/account-payment/account_prepayment/+merge/182021

[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.


-- 
https://code.launchpad.net/~jean-lelievre/account-payment/account_prepayment/+merge/182021
Your team Account Payment is requested to review the proposed merge of lp:~jean-lelievre/account-payment/account_prepayment into lp:account-payment.
=== added directory 'account_prepayment'
=== added file 'account_prepayment/__init__.py'
--- account_prepayment/__init__.py	1970-01-01 00:00:00 +0000
+++ account_prepayment/__init__.py	2013-08-26 03:48:18 +0000
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Andy Lu <andy.lu@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import account
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== added file 'account_prepayment/__openerp__.py'
--- account_prepayment/__openerp__.py	1970-01-01 00:00:00 +0000
+++ account_prepayment/__openerp__.py	2013-08-26 03:48:18 +0000
@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Andy Lu <andy.lu@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+    'name': 'Prepayment',
+    'version': '1.0',
+    'category': 'Account',
+    'sequence': 20,
+    'summary': 'Account Prepayment',
+    'description': """
+Prepayment Module For Opentrading
+==================================================
+Fine tune Prepayment addon \n
+* Add Prepayment Account In Partner \n
+* Add purchase_order_id and Prepayment Account in payment. 
+    """,
+    'author': 'Elico Corp',
+    'website': 'http://www.elico-corp.com',
+    'images' : [],
+    'depends': ['account', 'account_voucher', 'purchase'],
+    'data': [
+        'account_view.xml',
+    ],
+    'test': [],
+    'demo': [],
+    'installable': True,
+    'auto_install': False,
+    'application': False,
+}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== added file 'account_prepayment/account.py'
--- account_prepayment/account.py	1970-01-01 00:00:00 +0000
+++ account_prepayment/account.py	2013-08-26 03:48:18 +0000
@@ -0,0 +1,107 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (c) 2010-2013 Elico Corp. All Rights Reserved.
+#    Author: Andy Lu <andy.lu@xxxxxxxxxxxxxx>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+from tools.translate import _
+
+class res_partner(osv.osv):
+    _inherit = 'res.partner'
+
+    _columns = {
+        'property_account_prepayable': fields.property(
+            'account.account',
+            type='many2one',
+            relation='account.account',
+            string="Account payable (Prepayment)",
+            view_load=True,
+            domain="[('type', '=', 'payable')]",
+            help="This account will be used instead of the default one as the Prepayment payable account for the current partner",
+            required=True),
+        'property_account_prereceivable': fields.property(
+            'account.account',
+            type='many2one',
+            relation='account.account',
+            string="Account Receivable (Prepayment)",
+            view_load=True,
+            domain="[('type', '=', 'receivable')]",
+            help="This account will be used instead of the default one as the Prepayment receivable account for the current partner",
+            required=True),
+    }
+
+class account_voucher(osv.osv):
+    _inherit = "account.voucher"
+    
+    _columns = {
+        'purchase_id': fields.many2one('purchase.order', 'Purchase Order', domain=[('invoiced','=', False)], ondelete='set null'),
+        'use_prepayment_account': fields.boolean('Use Prepayment account', help="Check this if you want to input a prepayment on the prepayment accounts."),
+    }
+    _defaults = {
+        'use_prepayment_account': False,
+    }
+
+    def onchange_purchase_id(self, cr, uid, ids, purchase_id):
+        res = {}
+        if not purchase_id:
+            return res
+                
+        amount = 0
+        po_obj = self.pool.get('purchase.order')
+        po = po_obj.browse(cr, uid, purchase_id)
+        if po.invoiced:
+            res['warning'] = {'title': _('Warning!'), 'message': _('Selected Purchase Order was paid.')}
+        for invoice in po.invoice_ids:
+            if invoice.state in ('paid'):
+                amount += invoice.amount_total
+        res['value'] = {'partner_id': po.partner_id.id, 'amount': po.amount_total - amount}  
+        return res
+
+    def onchange_prepayment_account(self, cr, uid, ids, use_prepayment_account):
+        res = {}
+        if not use_prepayment_account:
+            return res
+
+        res['value'] = {'line_cr_ids': [],'line_dr_ids': [],'line_ids': []}  
+        return res
+
+    def writeoff_move_line_get(self, cr, uid, voucher_id, line_total, move_id, name, company_currency, current_currency, context=None):
+        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)
+        if line_vals:            
+            account_id = False
+            voucher_brw = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context)
+            if voucher_brw.use_prepayment_account:
+                if voucher_brw.payment_option == 'with_writeoff':
+                    account_id = voucher_brw.writeoff_acc_id.id
+                elif voucher_brw.type in ('sale', 'receipt'):
+                    if not voucher_brw.partner_id.property_account_prereceivable:
+                        raise osv.except_osv(_('Unable to validate payment !'), _('Please configure the partner Prereceivable Account at first!'))
+                    account_id = voucher_brw.partner_id.property_account_prereceivable.id
+                else:
+                    if not voucher_brw.partner_id.property_account_prepayable:
+                        raise osv.except_osv(_('Unable to validate payment !'), _('Please configure the partner Prepayable Account at first!'))
+                    account_id = voucher_brw.partner_id.property_account_prepayable.id
+                if account_id:                    
+                    line_vals['account_id'] = account_id
+        return line_vals
+account_voucher()
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'account_prepayment/account_view.xml'
--- account_prepayment/account_view.xml	1970-01-01 00:00:00 +0000
+++ account_prepayment/account_view.xml	2013-08-26 03:48:18 +0000
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+        
+        <!--
+        Partners Extension
+        -->
+        <record id="view_partner_preaccount_property_form" model="ir.ui.view">
+            <field name="name">res.partner.preaccount.property.form.inherit</field>
+            <field name="model">res.partner</field>
+            <field name="priority">3</field>
+            <field name="inherit_id" ref="account.view_partner_property_form"/>
+            <field name="arch" type="xml">
+				<xpath expr="//field[@name='property_account_receivable']" position="after">
+					<field name="property_account_prereceivable" groups="account.group_account_invoice" />
+		        </xpath>
+				<xpath expr="//field[@name='property_account_payable']" position="after">
+					<field name="property_account_prepayable" groups="account.group_account_invoice" />
+		        </xpath>
+            </field>
+        </record>    
+        
+		<record model="ir.ui.view" id="view_vendor_prepayment_form">
+            <field name="name">account.voucher.prepayment.form</field>
+            <field name="model">account.voucher</field>
+			<field name="inherit_id" ref="account_voucher.view_vendor_payment_form" />
+			<field name="arch" type="xml">
+				<xpath expr="//field[@name='partner_id']" position="before">
+					<field name="purchase_id" on_change="onchange_purchase_id(purchase_id)" />
+		        </xpath>
+				<xpath expr="//field[@name='journal_id']" position="after">
+					<field name="use_prepayment_account" on_change="onchange_prepayment_account(use_prepayment_account)"/>
+		        </xpath>				
+			</field>
+		</record>   
+        
+		<record model="ir.ui.view" id="view_vendor_prereceipt_form">
+            <field name="name">account.voucher.prereceipt.form</field>
+            <field name="model">account.voucher</field>
+			<field name="inherit_id" ref="account_voucher.view_vendor_receipt_form" />
+			<field name="arch" type="xml">
+				<xpath expr="//field[@name='journal_id']" position="after">
+					<field name="use_prepayment_account"/>
+		        </xpath>				
+			</field>
+		</record>
+
+    </data>    
+    
+    <!-- data noupdate="True">
+        <record id="prepayable_account_property" model="ir.property">
+            <field name="name">property_account_prepayable</field>
+            <field name="fields_id" ref="fc_account_prepayment.field_res_partner_property_account_prepayable"/>
+             <field name="company_id" ref="base.main_company"/>
+            <field eval="'account.account,'+str(ref('l10n_cn.chart1123'))" model="account.account" name="value"/>
+        </record>
+        <record id="prereceivable_account_property" model="ir.property">
+            <field name="name">property_account_prereceivable</field>
+            <field name="fields_id" ref="fc_account_prepayment.field_res_partner_property_account_prereceivable"/>
+             <field name="company_id" ref="base.main_company"/>
+            <field eval="'account.account,'+str(ref('l10n_cn.chart2205'))" model="account.account" name="value"/>
+        </record>
+    </data -->
+    
+</openerp>

=== added directory 'account_prepayment/i18n'
=== added file 'account_prepayment/i18n/zh_CN.po'
--- account_prepayment/i18n/zh_CN.po	1970-01-01 00:00:00 +0000
+++ account_prepayment/i18n/zh_CN.po	2013-08-26 03:48:18 +0000
@@ -0,0 +1,81 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* fc_account_prepayment
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0alpha\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-03-13 06:33+0000\n"
+"PO-Revision-Date: 2013-03-13 06:33+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: fc_account_prepayment
+#: field:res.partner,property_account_prepayable:0
+msgid "Account Prepayable"
+msgstr "预付科目"
+
+#. module: fc_account_prepayment
+#: code:addons/fc_account_prepayment/account.py:70
+#, python-format
+msgid "Please configure the partner Prereceivable Account at first!"
+msgstr "请先配置客户预收账款科目!"
+
+#. module: fc_account_prepayment
+#: model:ir.model,name:fc_account_prepayment.model_account_voucher
+msgid "Accounting Voucher"
+msgstr "手工凭证"
+
+#. module: fc_account_prepayment
+#: code:addons/fc_account_prepayment/account.py:74
+#, python-format
+msgid "Please configure the partner Prepayable Account at first!"
+msgstr "请先配置供应商预付账款科目!"
+
+#. module: fc_account_prepayment
+#: help:res.partner,property_account_prereceivable:0
+msgid "This account will be used instead of the default one as the prereceivable account for the current partner"
+msgstr "当前客户的预收账款科目"
+
+#. module: fc_account_prepayment
+#: help:account.voucher,use_prepayment_account:0
+msgid "Check this if you receive or pay amounts in advance."
+msgstr "如果你要创建预收或者预付凭证,请选择此项."
+
+#. module: fc_account_prepayment
+#: code:addons/fc_account_prepayment/account.py:70
+#: code:addons/fc_account_prepayment/account.py:74
+#, python-format
+msgid "Unable to validate payment !"
+msgstr "不能审核该笔支付 !"
+
+#. module: fc_account_prepayment
+#: field:account.voucher,purchase_id:0
+msgid "Use Prepayment account"
+msgstr "采购订单"
+
+#. module: fc_account_prepayment
+#: field:account.voucher,use_prepayment_account:0
+msgid "Use Prepayment account"
+msgstr "使用预付/预收科目"
+
+#. module: fc_account_prepayment
+#: help:res.partner,property_account_prepayable:0
+msgid "This account will be used instead of the default one as the prepayable account for the current partner"
+msgstr "当前供应商的预付账款科目"
+
+#. module: fc_account_prepayment
+#: model:ir.model,name:fc_account_prepayment.model_res_partner
+msgid "Partner"
+msgstr "业务伙伴"
+
+#. module: fc_account_prepayment
+#: field:res.partner,property_account_prereceivable:0
+msgid "Account Prereceivable"
+msgstr "预收科目"
+


References