This question has been flagged
3 Replies
3505 Views

I want to displayed the  *Or Number, P.R Number, Cheque Number while paying in SALES and C.V. number  and Cheque Number while paying at PURCHASE.. how will i going to do that? Please anyone help me.

Avatar
Discard
Best Answer

Do you have any field on that form (or object) that indicates which payment it is (sale or purchase)? If so, you could use the "attrs" property on those fields and make them invisible in the case of sale or purchase.

Do note however, the fields cannot be mandatory if they are invisible, so if you want that to happen you need to also provide "required" in your attrs-statement.

Hope this helps!

Avatar
Discard
Author

i don't have fields. Can you teach how to add that?

If there is no field indicating which payment type this is, then perhaps take a step back. In the original invoice to be paid, there must be an indication (the field named "type" should be good). When clicking the button, you might consider overriding the method that follows, allowing you to save that value in context. Perhaps the invoice)id is already sent in this screen? Try using that to identify which payment type this is and hide the fields based on that value.

Author

Thanks Ludo:)

Best Answer

I think, you should make 2 different view, each for sale and purchase invoice. And provide two action to trigger each view. Because hidding things from the same object for to difference purpose is not a good practice.

Btw, if you insist want to control visibility of some field you can use customer / supplier boolead field in res.partner model.

Some inconsistent data I see is that you need purchase data for customer.

Avatar
Discard

An even better suggestion. Thnx ben!

Author

hi, Ben i did that but it didn't work i don't know why. I'll post my codes.

Author Best Answer

Here is my code:

 


<!--    ***************************SALE VIEW******************************************    -->
        <record id="account_voucher_receipt_dialog_form_view_inherit_sale" model="ir.ui.view">
            <field name="name">account.voucher.payment.form</field>
            <field name="model">account.voucher</field>
            <field name="inherit_id" ref="account_voucher.view_vendor_receipt_dialog_form" />
            <field name="priority" eval="30"/>
            <field name="arch" type="xml">
                <data>
                    <xpath expr="//field[@name='reference']" position="after">
                        <field name="or_num" invisible="context.get('line_type', False)" string="O.R. Number" placeholder="e.g. OR003/10"/>
                        <field name="cheque_num" invisible="context.get('line_type', False)" string="Checque Number" placeholder="e.g. Checque003/10"/>
                        <field name="pr_num" invisible="context.get('line_type', False)" string="P.R. Number" placeholder="e.g. PR003/10"/>
                        <field name="cv_num" invisible="context.get('line_type', False)" string="C.V.Number" placeholder="e.g. CV003/10"/>
                        <field name="sale_bo" invisible="False"/>
                        <field name="purchase_bo" invisible="False"/>
                        
                    </xpath>
                </data>
            </field>
        </record>
<!--        -->
<!--    ***************************PURCHASE VIEW******************************************            -->
        <record id="account_voucher_receipt_dialog_form_view_inherit_purchase" model="ir.ui.view">
            <field name="name">account.voucher.payment.form</field>
            <field name="model">account.voucher</field>
            <field name="inherit_id" ref="account_voucher.view_vendor_receipt_dialog_form" />
            <field name="priority" eval="30"/>
            <field name="arch" type="xml">
                <data>
                    <xpath expr="//field[@name='reference']" position="after">
<!--                        <field name="or_num" invisible="context.get('line_type', False)" string="O.R. Number" placeholder="e.g. OR003/10"/>-->
<!--                        <field name="cheque_num" invisible="context.get('line_type', False)" string="Checque Number" placeholder="e.g. Checque003/10"/>-->
<!--                        <field name="pr_num" invisible="context.get('line_type', False)" string="P.R. Number" placeholder="e.g. PR003/10"/>-->
                        <field name="cv_num" invisible="context.get('line_type', False)" string="C.V.Number" placeholder="e.g. CV003/10"/>
                        <field name="purchase_bo" invisible="True"/>
                        
                    </xpath>
                </data>
            </field>
        </record>
<!--        -->
<!--    ***************************SALE******************************************    -->
         <record id="action_vendor_receipt_sale" model="ir.actions.act_window">
            <field name="name">Customer Payments</field>
            <field name="res_model">account.voucher</field>
            <field name="view_type">form</field>
            <field name="domain">[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','receipt')]</field>
            <field name="context">{'type':'receipt','default_sale_bo':'1'}</field>
            <field name="search_view_id" ref="account_voucher.view_voucher_filter_customer_pay"/>
            <field name="view_id" eval="False"/>
            <field name="target">current</field>
            <field name="form_view_id" ref="account_voucher_receipt_dialog_form_view_inherit_sale" />
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                Click to register a new payment.
              </p><p>
                Enter the customer and the payment method and then, either
                create manually a payment record or OpenERP will propose to you
                automatically the reconciliation of this payment with the open
                invoices or sales receipts.
              </p>
            </field>
        </record>
        
<!--    ***************************PURCHASE******************************************    -->
         <record id="action_vendor_receipt_purchase" model="ir.actions.act_window">
            <field name="name">Customer Payments</field>
            <field name="res_model">account.voucher</field>
            <field name="view_type">form</field>
            <field name="domain">[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','receipt')]</field>
            <field name="context">{'type':'receipt', 'purchase_bo','=','1'}</field>
            <field name="search_view_id" ref="account_voucher.view_voucher_filter_customer_pay"/>
            <field name="view_id" eval="False"/>
            <field name="target">current</field>
<!--            <field name="form_view_id" ref="account_voucher_receipt_dialog_form_view_inherit_sale" />-->
            <field name="form_view_id" ref="account_voucher_receipt_dialog_form_view_inherit_purchase" />
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                Click to register a new payment.
              </p><p>
                Enter the customer and the payment method and then, either
                create manually a payment record or OpenERP will propose to you
                automatically the reconciliation of this payment with the open
                invoices or sales receipts.
              </p>
            </field>
        </record>

 

Avatar
Discard