Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
4580 Vizualizări

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.

Imagine profil
Abandonează
Autor

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

Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
dec. 24
1750
0
nov. 23
1603
0
mai 21
19
1
nov. 24
1590
1
iul. 25
1839