[ADD] account_voucher: implement writeoff on customer and vendor payment
[odoo/odoo.git] / addons / account_voucher / voucher_payment_receipt_view.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <openerp>
3     <data>
4
5         <record id="view_voucher_filter_customer_pay" model="ir.ui.view">
6             <field name="name">account.voucher.customer.pay.select</field>
7             <field name="model">account.voucher</field>
8             <field name="type">search</field>
9             <field name="arch" type="xml">
10                 <search string="Search Vouchers">
11                     <group col='8' colspan='4'>
12                         <filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Vouchers"/>
13                         <filter icon="terp-camera_test" string="Posted" domain="[('state','=','posted')]" help="Posted Vouchers"/>
14                         <separator orientation="vertical"/>
15                         <filter icon="terp-gtk-jump-to-ltr" string="To Review" domain="[('state','=','posted')]" groups="base.group_extended" help="To Review"/>
16                         <separator orientation="vertical"/>
17                         <field name="date"/>
18                         <field name="number"/>
19                         <field name="partner_id" string="Customer"/>
20                     </group>
21                     <newline/>
22                     <group col='8' colspan='4'>
23                         <field name="journal_id" widget="selection" context="{'journal_id': self, 'set_visible':False}" domain="[('type','in',('bank','cash'))]"/>
24                         <field name="period_id" groups="base.group_extended"/>
25                     </group>
26                     <newline/>
27                     <group expand="0" string="Extended Filters..." col='8' colspan='4'>
28                         <field name="reference"/>
29                         <field name="name"/>
30                         <field name="narration"/>
31                         <field name="amount"/>
32                    </group>
33                    <newline/>
34                     <group expand="0" string="Group By..." colspan="4" col="10">
35                         <filter string="Customer" icon="terp-personal" domain="[]" context="{'group_by':'partner_id'}"/>
36                         <filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/>
37                         <filter string="Period" icon="terp-go-month" domain="[]" context="{'group_by':'period_id','visible':True}"/>
38                         <filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
39                     </group>
40                 </search>
41             </field>
42         </record>
43
44
45         <record id="view_voucher_filter_vendor_pay" model="ir.ui.view">
46             <field name="name">account.voucher.purchase.pay.select</field>
47             <field name="model">account.voucher</field>
48             <field name="type">search</field>
49             <field name="arch" type="xml">
50                 <search string="Search Vouchers">
51                     <group col='8' colspan='4'>
52                         <filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Vouchers"/>
53                         <filter icon="terp-camera_test" string="Posted" domain="[('state','=','posted')]" help="Posted Vouchers"/>
54                         <separator orientation="vertical"/>
55                         <filter icon="terp-gtk-jump-to-ltr" string="To Review" domain="[('state','=','posted')]" groups="base.group_extended" help="To Review"/>
56                         <separator orientation="vertical"/>
57                         <field name="date"/>
58                         <field name="number"/>
59                         <field name="partner_id" string="Supplier"/>
60                     </group>
61                     <newline/>
62                     <group col='8' colspan='4'>
63                         <field name="journal_id" widget="selection" context="{'journal_id': self, 'set_visible':False}" domain="[('type','in',('bank','cash'))]"/>
64                         <field name="period_id" groups="base.group_extended"/>
65                     </group>
66                     <newline/>
67                     <group expand="0" string="Extended Filters..." col='8' colspan='4'>
68                         <field name="reference"/>
69                         <field name="name"/>
70                         <field name="narration"/>
71                         <field name="amount"/>
72                    </group>
73                    <newline/>
74                     <group expand="0" string="Group By..." colspan="4" col="10">
75                         <filter string="Supplier" icon="terp-personal" domain="[]" context="{'group_by':'partner_id'}"/>
76                         <filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/>
77                         <filter string="Period" icon="terp-go-month" domain="[]" context="{'group_by':'period_id','visible':True}"/>
78                         <filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
79                     </group>
80                 </search>
81             </field>
82         </record>
83         <record model="ir.ui.view" id="view_low_priority_payment_form">
84             <field name="name">account.voucher.payment.low.priority.form</field>
85             <field name="model">account.voucher</field>
86             <field name="type">form</field>
87             <field name="priority">1</field>
88             <field name="arch" type="xml">
89                 <form string="Bill Payment">
90                     <group col="6" colspan="4">
91                         <field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)" context="{'invoice_currency':currency_id}" string="Vendor"/>
92                         <field name="journal_id"
93                             domain="[('type','in',['bank', 'cash'])]"
94                             widget="selection" select="1"
95                             on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)"
96                             string="Payment Method"/>
97                         <field name="amount" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)"/>
98                         <field name="reference" select="1" string="Payment Ref"/>
99                         <field name="name" colspan="4"/>
100                         <field name="account_id"
101                             widget="selection"
102                             invisible="True"/>
103                         <field name="pre_line" invisible="1"/>
104                         <field name="type" invisible="True"/>
105                     </group>
106                     <notebook colspan="4">
107                         <page string="Payment Information">
108                             <field name="line_dr_ids" attrs="{'invisible': [('type', '=', 'receipt')]}" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140">
109                                 <tree string="Open Vendor Journal Entries" editable="bottom">
110                                     <field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
111                                         on_change="onchange_move_line_id(move_line_id)"
112                                         domain="[('account_id.type','=','payable'), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
113                                         />
114                                     <field name="account_id" groups="base.group_extended" domain="[('type','=','payable')]"/>
115                                     <field name="date_original" readonly="1"/>
116                                     <field name="date_due" readonly="1"/>
117                                     <field name="amount_original" readonly="1"/>
118                                     <field name="amount_unreconciled" sum="Open Balance" readonly="1"/>
119                                     <field name="amount" sum="Payment"/>
120                                 </tree>
121                             </field>
122                             <field name="line_cr_ids" colspan="4" nolabel="1" attrs="{'invisible': [('type', '=', 'payment')]}" default_get="{'journal_id':journal_id, 'partner_id':partner_id}">
123                                 <tree string="Open Customer Journal Entries" editable="bottom">
124                                     <field name="move_line_id"/>
125                                     <field name="account_id" groups="base.group_extended" domain="[('type','=','receivable')]"/>
126                                     <field name="date_original"/>
127                                     <field name="amount_original"/>
128                                     <field name="amount" sum="Payment"/>
129                                 </tree>
130                             </field>
131                             <group col="2" colspan="3">
132                                 <separator string="Internal Notes" colspan="2"/>
133                                 <field name="narration" colspan="2" nolabel="1"/>
134                             </group>
135                             <group col="2" colspan="1">
136                                 <separator string="Other Information" colspan="2"/>
137                                 <field name="date" select="1" on_change="onchange_date(date)"/>
138                                 <field name="currency_id" invisible="True"/>
139                                 <field name="number"/>
140                             </group>
141                         </page>
142                     </notebook>
143                 </form>
144             </field>
145         </record>
146
147         <record model="ir.ui.view" id="view_vendor_payment_form">
148             <field name="name">account.voucher.payment.form</field>
149             <field name="model">account.voucher</field>
150             <field name="type">form</field>
151             <field name="arch" type="xml">
152                 <form string="Bill Payment">
153                     <group col="6" colspan="4">
154                         <field name="partner_id" domain="[('supplier','=',True)]" required="1" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)" context="{'invoice_currency':currency_id}" string="Vendor"/>
155                         <field name="journal_id"
156                             domain="[('type','in',['bank', 'cash'])]"
157                             widget="selection" select="1"
158                             on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)"
159                             string="Payment Method"/>
160                         <field name="amount" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)"/>
161                         <field name="reference" select="1" string="Payment Ref"/>
162                         <field name="name" colspan="4"/>
163                         <field name="account_id"
164                             widget="selection"
165                             invisible="True"/>
166                         <field name="pre_line" invisible="1"/>
167                         <field name="type" invisible="True"/>
168                     </group>
169                     <notebook colspan="4">
170                         <page string="Payment Information">
171                             <field name="line_dr_ids" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140">
172                                 <tree string="Vendor Invoices and Outstanding transactions" editable="bottom">
173                                     <field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
174                                         on_change="onchange_move_line_id(move_line_id)"
175                                         domain="[('account_id.type','=','payable'), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
176                                         />
177                                     <field name="account_id" groups="base.group_extended" domain="[('type','=','payable')]"/>
178                                     <field name="date_original" readonly="1"/>
179                                     <field name="date_due" readonly="1"/>
180                                     <field name="amount_original" readonly="1"/>
181                                     <field name="amount_unreconciled" sum="Open Balance" readonly="1"/>
182                                     <field name="amount" sum="Payment"/>
183                                 </tree>
184                             </field>
185                             <field name="line_cr_ids" colspan="4" nolabel="1" attrs="{'invisible': [('pre_line','=',False)]}" default_get="{'journal_id':journal_id, 'partner_id':partner_id}">
186                                 <tree string="Credits" editable="bottom">
187                                     <field name="move_line_id"/>
188                                     <field name="account_id" groups="base.group_extended" domain="[('type','=','receivable')]"/>
189                                     <field name="date_original"/>
190                                     <field name="amount_original"/>
191                                     <field name="amount" sum="Payment"/>
192                                 </tree>
193                             </field>
194                             <group col="2" colspan="3">
195                                 <separator string="Internal Notes" colspan="2"/>
196                                 <field name="narration" colspan="2" nolabel="1"/>
197                             </group>
198                             <group col="2" colspan="1">
199                                 <group col="2" colspan="1">
200                                     <separator string="Payment Options" colspan="2"/>
201                                     <field name="payment_option" required="1"/>
202                                     <field name="writeoff_acc_id"
203                                            attrs="{'invisible':[('payment_option','!=','close_balance')], 'required':[('payment_option','=','close_balance')]}"
204                                            domain="[('type','=','liquidity')]"/>
205                                          <!-- should select income accounts only. Or use the journal for this ? -->
206                                     <field name="writeoff_journal_id"
207                                            attrs="{'invisible':[('payment_option','!=','close_balance')], 'required':[('payment_option','=','close_balance')]}"/>
208                                     <field name="comment"
209                                            attrs="{'invisible':[('payment_option','!=','close_balance')]}"/>
210                                     <field name="analytic_id"
211                                            attrs="{'invisible':[('payment_option','!=','close_balance')]}"
212                                            groups="analytic.group_analytic_accounting"/>
213                                 </group>
214                                 <separator string="Other Information" colspan="2"/>
215                                 <group col="4" colspan="1">
216                                   <field name="date" select="1" on_change="onchange_date(date)"/>
217                                   <field name="currency_id" invisible="True"/>
218                                   <field name="number"/>
219                                 </group>
220                             </group>
221                         </page>
222                         <page string="Journal Items" groups="base.group_extended" attrs="{'invisible': [('state','!=','posted')]}">
223                             <group col="6" colspan="4">
224                                 <field name="company_id" select="1" widget="selection" groups="base.group_multi_company"/>
225                                 <field name="period_id"/>
226                                 <field name="audit"/>
227                             </group>
228                             <separator string="Journal Items" colspan="4"/>
229                             <field name="move_ids" colspan="4" nolabel="1" readonly="1"/>
230                         </page>
231                     </notebook>
232                     <group col="10" colspan="4">
233                         <field name="state"/>
234                         <button name="cancel_voucher" string="Cancel" states="draft,proforma"  icon="gtk-cancel"/>
235                         <button name="cancel_voucher" string="Unreconcile" type="object" states="posted" icon="terp-stock_effects-object-colorize" confirm="Are you sure to unreconcile this record ?"/>
236                         <button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft" icon="terp-stock_effects-object-colorize"/>
237                         <button name="proforma_voucher" string="Validate" states="draft" icon="gtk-go-forward"/>
238                     </group>
239                 </form>
240             </field>
241         </record>
242
243         <record id="action_vendor_payment" model="ir.actions.act_window">
244             <field name="name">Vendor Payment</field>
245             <field name="res_model">account.voucher</field>
246             <field name="view_type">form</field>
247             <field name="domain">[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','payment')]</field>
248             <field name="context">{'type':'payment'}</field>
249             <field name="view_id" eval="False"/>
250             <field name="search_view_id" ref="view_voucher_filter_vendor_pay"/>
251             <field name="target">current</field>
252             <field name="help">The supplier payment form allows you to track the payment you do to your suppliers. When you select a supplier, the payment method and an amount for the payment, OpenERP will propose to reconcile your payment with the open supplier invoices or bills.</field>
253         </record>
254         <record id="action_vendor_payment_tree" model="ir.actions.act_window.view">
255             <field eval="1" name="sequence"/>
256             <field name="view_mode">tree</field>
257             <field name="act_window_id" ref="action_vendor_payment"/>
258         </record>
259         <record id="action_vendor_payment_form" model="ir.actions.act_window.view">
260             <field eval="2" name="sequence"/>
261             <field name="view_mode">form</field>
262             <field name="view_id" ref="view_vendor_payment_form"/>
263             <field name="act_window_id" ref="action_vendor_payment"/>
264         </record>
265
266
267         <menuitem action="action_vendor_payment" icon="STOCK_JUSTIFY_FILL" sequence="12"
268             id="menu_action_vendor_payment"  parent="account.menu_finance_payables"/>
269
270         <record model="ir.ui.view" id="view_vendor_receipt_form">
271             <field name="name">account.voucher.receipt.form</field>
272             <field name="model">account.voucher</field>
273             <field name="type">form</field>
274             <field name="arch" type="xml">
275                 <form string="Customer Payment">
276                     <group col="6" colspan="4">
277                         <field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)" string="Customer"/>
278                         <field name="journal_id"
279                             domain="[('type','in',['bank', 'cash'])]"
280                             widget="selection" select="1"
281                             on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)"
282                             string="Payment Method"/>
283                         <field name="amount"
284                             string="Paid Amount"
285                             on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type)"/>
286                         <field name="reference" select="1" string="Payment Ref"/>
287                         <field name="name" colspan="4"/>
288                         <field name="account_id"
289                             widget="selection"
290                             invisible="True"/>
291                         <field name="pre_line" invisible="1"/>
292                         <field name="type" invisible="True"/>
293                     </group>
294                     <notebook colspan="4">
295                         <page string="Payment Information">
296                             <field name="line_cr_ids" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140">
297                                 <tree string="Invoices and outstanding transactions" editable="bottom">
298                                     <field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}"
299                                         on_change="onchange_move_line_id(move_line_id)"
300                                         domain="[('account_id.type','in',('receivable','payable')), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]"
301                                         />
302                                     <field name="account_id"  groups="base.group_extended" domain="[('type','=','receivable')]"/>
303                                     <field name="date_original" readonly="1"/>
304                                     <field name="date_due" readonly="1"/>
305                                     <field name="amount_original" readonly="1"/>
306                                     <field name="amount_unreconciled" sum="Open Balance" readonly="1"/>
307                                     <field name="amount" sum="Payment"/>
308                                 </tree>
309                             </field>
310                             <field name="line_dr_ids" colspan="4" nolabel="1" attrs="{'invisible': [('pre_line','=',False)]}" default_get="{'journal_id':journal_id, 'partner_id':partner_id}">
311                                 <tree string="Credits" editable="bottom">
312                                     <field name="move_line_id"/>
313                                     <field name="account_id"  groups="base.group_extended" domain="[('type','=','receivable')]"/>
314                                     <field name="date_original"/>
315                                     <field name="amount_original"/>
316                                     <field name="amount" sum="Payment"/>
317                                 </tree>
318                             </field>
319                             <group col="2" colspan="3">
320                                 <separator string="Internal Notes" colspan="2"/>
321                                 <field name="narration" colspan="2" nolabel="1"/>
322                             </group>
323                             <group col="2" colspan="1">
324                                 <group col="2" colspan="1">
325                                     <separator string="Payment Options" colspan="2"/>
326                                     <field name="payment_option" required="1"/>
327                                     <field name="writeoff_acc_id"
328                                            attrs="{'invisible':[('payment_option','!=','close_balance')], 'required':[('payment_option','=','close_balance')]}"
329                                            domain="[('type','=','liquidity')]"/>
330                                          <!-- should select income accounts only. Or use the journal for this ? -->
331                                     <field name="writeoff_journal_id"
332                                            attrs="{'invisible':[('payment_option','!=','close_balance')], 'required':[('payment_option','=','close_balance')]}"/>
333                                     <field name="comment"
334                                            attrs="{'invisible':[('payment_option','!=','close_balance')]}"/>
335                                     <field name="analytic_id"
336                                            attrs="{'invisible':[('payment_option','!=','close_balance')]}"
337                                            groups="analytic.group_analytic_accounting"/>
338                                 </group>
339                                 <separator string="Other Information" colspan="2"/>
340                                 <group col="4" colspan="1">
341                                     <field name="date" select="1" on_change="onchange_date(date)"/>
342                                     <field name="currency_id" invisible="True"/>
343                                     <field name="number"/>
344                                 </group>
345                             </group>
346                         </page>
347                         <page string="Journal Items" groups="base.group_extended" attrs="{'invisible': [('state','!=','posted')]}">
348                             <group col="6" colspan="4">
349                                 <field name="company_id" select="1" widget="selection" groups="base.group_multi_company"/>
350                                 <field name="period_id"/>
351                                 <field name="audit"/>
352                             </group>
353                             <separator string="Journal Items" colspan="4"/>
354                             <field name="move_ids" colspan="4" nolabel="1" readonly="1"/>
355                         </page>
356                     </notebook>
357                     <group col="10" colspan="4">
358                         <field name="state"/>
359                         <button name="cancel_voucher" string="Cancel" states="draft,proforma"  icon="gtk-cancel"/>
360                         <button name="cancel_voucher" string="Unreconcile" type="object" states="posted" icon="terp-stock_effects-object-colorize" confirm="Are you sure to unreconcile this record ?"/>
361                         <button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft" icon="terp-stock_effects-object-colorize"/>
362                         <button name="proforma_voucher" string="Validate" states="draft" icon="gtk-go-forward"/>
363                     </group>
364                 </form>
365             </field>
366         </record>
367
368         <record id="action_vendor_receipt" model="ir.actions.act_window">
369             <field name="name">Customer Payment</field>
370             <field name="res_model">account.voucher</field>
371             <field name="view_type">form</field>
372             <field name="domain">[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','receipt')]</field>
373             <field name="context">{'type':'receipt'}</field>
374             <field name="search_view_id" ref="view_voucher_filter_customer_pay"/>
375             <field name="view_id" eval="False"/>
376             <field name="target">current</field>
377             <field name="help">Sales payment allows you to register the payments you receive from your customers. In order to record a payment, you must enter the customer, the payment method (=the journal) and the payment amount. OpenERP will propose to you automatically the reconciliation of this payment with the open invoices or sales receipts.</field>
378         </record>
379         <record id="action_vendor_receipt_tree" model="ir.actions.act_window.view">
380             <field eval="1" name="sequence"/>
381             <field name="view_mode">tree</field>
382             <field name="act_window_id" ref="action_vendor_receipt"/>
383         </record>
384         <record id="action_vendor_receipt_form" model="ir.actions.act_window.view">
385             <field eval="2" name="sequence"/>
386             <field name="view_mode">form</field>
387             <field name="view_id" ref="view_vendor_receipt_form"/>
388             <field name="act_window_id" ref="action_vendor_receipt"/>
389         </record>
390
391         <menuitem action="action_vendor_receipt" icon="STOCK_JUSTIFY_FILL" sequence="12"
392             id="menu_action_vendor_receipt"  parent="account.menu_finance_receivables"/>
393     </data>
394 </openerp>