Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
7 Odpowiedzi
10489 Widoki

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

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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


Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć

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

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

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

Najlepsza odpowiedź

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


Awatar
Odrzuć
Najlepsza odpowiedź

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

 



Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
mar 19
3173
0
mar 15
4903
1
sie 25
3808
1
lut 25
5353
3
lis 24
1074