Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
4548 Vues

I have added a new character field to the "res.partner" model in my Odoo application named "customer_level". My intention is to make this field visible in the Point of Sale module. This way, when a cashier searches for a customer, they will be able to view the corresponding customer level information.

I was able to add the "customer_level" field to the Point of Sale module in Odoo 15, but I am encountering issues when trying to reuse the same code in Odoo 16.

I will provide codes how did I add to Odoo 15.

my pos.js is located at my custom module, /src/user/my_module/static/src/js/pos.js

`odoo.define('pos.Pos', function (require) {
"use strict";
 
var models = require('point_of_sale.models');
var fields = models.load_fields('res.partner', 'customer_level'); 
});`

Here is my pos.xml at /src/user/my_module/static/src/xml/pos.xml

``
 
 



Type











 





Customer Type




 

 
 
 

`



`


It works perfectly at Odoo 15, I wonder why this code does not work at Odoo 16. I have changed "ClientListScreen" to "PartnerLineScreen" and "ClientLine" to "PartnerLine" accordingly at my codes to work with Odoo 16 but field is not appeared at "PartnerLineScreen". Kindly help me I am stucked.

Avatar
Ignorer
Auteur

Here is my pos.xml at /src/user/my_module/static/src/xml/pos.xml
`<?xml version="1.0" encoding="UTF-8"?>
<templates id="pos_subscriber_template" inherit_id="point_of_sale.template" xml:space="preserve">

<!-- ClientListScreenWidget for Customer Type column-->
<t t-extend="ClientListScreenWidget" t-inherit="point_of_sale.ClientListScreen" t-inherit-mode="extension" owl="1">
<xpath expr="//table//thead//tr" position="inside">
<th>Type</th>
</xpath>
</t>

<!-- Getting value for Customer Type colun -->
<t t-extend="ClientLine" t-inherit="point_of_sale.ClientLine" t-inherit-mode="extension" owl="1">
<xpath expr="//tr" position="inside">
<td class="text-center">
<center><t t-esc='props.partner.customer_level or ""' /></center>
</td>
</xpath>
</t>

<!-- Customer Type column at Client Detials Edit -->
<t t-extend="ClientDetailsEdit" t-inherit="point_of_sale.ClientDetailsEdit" t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('client-details-left')]" position="inside">
<div class="client-detail">
<span class='label'>Customer Type</span>
<span> <t t-esc='props.partner.customer_level or ""'/></span>
</div>
</xpath>
</t>

<!-- Customer Type column at Client Detials Edit -->

</templates>
`

good code many thanks

Meilleure réponse

Hi, 
In odoo16 there are some technical changes for loading new fields in to pos

For adding the new field, we can use the _loader_params method, it is written as _loader_params_ followed by your model name.


try this in your python file



from odoo import models


class PosSession(models.Model):
_inherit = 'pos.session'

def
_loader_params_res_partner(self):
result = super()._loader_params_res_partner()
result['search_params']['fields'].append('customer_level')
return result


Hope this will help you
Thanks

Avatar
Ignorer
Publications associées Réponses Vues Activité
0
déc. 24
1699
0
nov. 23
1595
0
mai 21
19
1
nov. 24
1568
1
juil. 25
1827