Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

8

How to Change Custom icons for Payment Acquirers?

By
Ayaz Mansuri
on 3/28/16, 3:00 AM 1,373 views

Hello...!!!

Currently I'm Working on Payment Integration Module., But Unable to set custom icon/image for payment methods.

if we create custom payment module, payment_demo, it will be set like...

<img t-if="not submit_txt" src="/payment_demo/static/src/img/demo_icon.png"/>

 But, How can i set custom icon without creating custom payment module..!!!

Thanks,

Ayaz Mansuri

6

Hi Mansuri,


The image icon should be saved in this format 'acquirername_icon.png'

The payment methods in odoo e-commerce is listed by using this methode in the corresponding template

        <li t-foreach="acquirers or []" t-as="acquirer">

            <label t-if="acquirer.button">

                <input t-att-value="acquirer.id" type="radio" name="acquirer" t-att-checked="acquirers[0] == acquirer"/>

                <img class="media-object" style="width: 60px; display: inline-block;"

                    t-att-title="acquirer.name"

                    t-att-src="'/payment_%s/static/src/img/%s_icon.png' % (acquirer.provider, acquirer.provider)"/>

                <span t-field="acquirer.name"/>

            </label>

        </li>

I hope it will help.

Where is the file, script, to write this code ?

Lince
on 4/23/16, 3:36 AM

You don't need to include this code...its already there. just give name for that icon as mentioned in answer

fasluca
on 4/25/16, 1:05 AM

Hi Lince, At the time of installation of module 'payment_demo ' some datas are to be set in payment.acquirer as Demo demo test here you may need to create tempate demo_acquirer_button. Note: Look here the provider is 'demo'. You also have to inherit payment.acquirer and follow the code: class PaymentAcquirer(models.Model): _inherit = 'payment.acquirer' def _get_providers(self, cr, uid, context=None): providers = super(PaymentAcquirer, self)._get_providers(cr, uid, context=context) providers.append(['demo', 'demo']) return providers

nikesh
on 4/29/16, 2:31 AM
3
Ayaz Mansuri
On 5/2/16, 9:46 AM

Thank You Guys For your Contribution..but finally i've solved this without creating custom payment module, no need to place image in existing payment module, no need write methods., Just Put one field in payment acquirer model..like...

In Your Py File:

class acquirer(osv.Model):

    _inherit = 'payment.acquirer'

   _columns = { 

    'payment_icon': fields.char(string='Icon location', help='Custom icon to use for this acquirer.'),

}

In Your XML File:

<record id="acquirer_form_payment" model="ir.ui.view">

    <field name="name">acquirer.form.payerse</field>

    <field name="model">payment.acquirer</field>

    <field name="inherit_id" ref="payment.acquirer_form"/>

    <field name="arch" type="xml">

        <xpath expr='//group[@name="acquirer_display"]' position='after'>

    <group>

            <field name="payment_icon"/>

    </group>

        </xpath>

    </field>

</record> 

And...........

  <template id="payment_inherit" inherit_id="website_sale.payment">

    <!-- Enable custom icons in Payment Acquirers -->

    <xpath expr="//div[@id='payment_method']//img" position="attributes">

        <attribute name="t-att-src">acquirer.payment_icon or '/payment_%s/static/src/img/%s_icon.png' % (acquirer.provider, acquirer.provider)</attribute>

    </xpath>

</template>

Now Go to Settings > Payment Acquirers > Select any of payment Method > Go to payment_icon Field & Write icon image path like this. /your_module_name/static/src/img/lastschrift_icon.png

This is how you can change payment icons without creating custom payment module...!!!

Thanks...!!!


1
nikesh
On 4/29/16, 2:36 AM

Hi Lince,
At the time of installation of module 'payment_demo ' some datas are to be set in payment.acquirer as

 

<openerp>
    <data noupdate="1">
        <record id="payment_acquirer_sagepay" model="payment.acquirer">
            <field name="name">Demo</field>
            <field name="provider">demo</field>
            <field name="company_id" ref="base.main_company"/>
            <field name="view_template_id" ref="demo_acquirer_button"/>
            <field name="environment">test</field>
        </record>
    </data>
</openerp>


Here you may need to create tempate demo_acquirer_button.

 Note: Look here the provider is 'demo'. You also have to inherit payment.acquirer and follow the code:

class PaymentAcquirer(models.Model): 
    _inherit = 'payment.acquirer'
    def _get_providers(self, cr, uid, context=None):
        providers = super(PaymentAcquirer, self)._get_providers(cr, uid, context=context)
        providers.append(['demo', 'demo'])
        return providers


0

Prakash Sharma

--Prakash Sharma--
815
| 2 1 4
Delhi, India
--Prakash Sharma--

I like to surround myself with brave, creative people.

My motivation for learning different technologies and algos drive me. I love challenges of a steep learning curve which I believe makes me a better learner. I have a strong desire to learn different technologies, which would enable me to become a full stack developer.

Prakash Sharma
On 4/20/16, 6:33 AM

just place a icon as the name of acquire name in static/src/img.

For example if you want to change the image of payment_transfer;

place a  .png image  inside payment_transfer/static/src/img/ having name transfer_icon


For example if you want to change the image of payment_paypal;

place a  .png image  inside payment_paypal/static/src/img/ having name paypal_icon

 



Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/28/16, 3:00 AM
Seen: 1373 times
Last updated: 11/11/16, 7:01 AM