Skip to Content
Menu
This question has been flagged
1 Reply
7252 Views

Hi. I need to add custom field in pos customer view. I added this field in my Contacts app, and now I need to view info from this field in my pos customer view (list and edit). How I can implement this?

Here is my code , but the field still not displayed in pos interface , same for the label.

What's wrong please?



//.xml

  <template id="my_module.assets" inherit_id="point_of_sale.assets" name="point_of_sale assets">

      <xpath expr="." position="inside">

          <script type="text/javascript" src="/my_module/static/src/js/customer.js"></script>

      </xpath>

  </template>


//js

odoo.define('my_module.customer', function (require) {

"use strict";

var models = require('point_of_sale.models');

models.load_fields('res.partner', ['my_field']);

});


//.xml

<?xml version="1.0" encoding="UTF-8" ?>

<templates id="point_of_sale.template" xml:space="preserve">

<t t-extend="ClientDetailsEdit">

        <t t-jquery=".client-details-right" t-operation="append">

            <div class="client-detail">

                <span class="label">My Field</span>

                      <input class='detail client_my_field' name="my_field" type="date" t-att-value='partner.my_field'></input>

            </div>

        </t>

    </t>

    <t t-extend="ClientListScreen">

        <t t-jquery=".subwindow-container" t-operation="replace">

             <div class="subwindow-container">

                                <div t-if="!state.detailIsShown" class="subwindow-container-fix scrollable-y">

                                    <table class="client-list">

                                        <thead>

                                            <tr>

                                                <th>Name</th>

                                                <th t-if="!env.isMobile">Address</th>

                                                <th t-if="!env.isMobile">Phone</th>

                                                <th t-if="env.isMobile">ZIP</th>

                                                <th>Email</th>

                                                <th>My Field</th>

                                            </tr>

                                        </thead>

                                        <tbody class="client-list-contents">

                                            <t t-foreach="clients" t-as="partner"

                                               t-key="partner.id">

                                                <ClientLine partner="partner"

                                                            selectedClient="state.selectedClient"

                                                            detailIsShown="state.detailIsShown"

                                                            t-on-click-client="clickClient" />

                                            </t>

                                        </tbody>

                                    </table>

                                </div>

Thanks.
Avatar
Discard
Best Answer

Hi,

Please include this code in your JavaScript  file Then the new field will be displayed in pos interface.

var _super_posmodel = models.PosModel.prototype;
    models.PosModel = models.PosModel.extend({
        initialize: function(session,attributes)
        {
            var contact_model = _.find(this.models,function(model)
            {
                return model.model === 'res.partner';
            });
            contact_model.fields.push(‘my_field’);
            return _super_posmodel.initialize.call(this,session,attributes);
        },
    });

Regards

Avatar
Discard
Related Posts Replies Views Activity
2
Aug 24
5008
1
Oct 22
22114
2
Sep 21
11234
1
Jul 21
3436
1
Dec 23
23680