Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4559 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 12 24
1717
0
thg 11 23
1596
0
thg 5 21
19
1
thg 11 24
1578
1
thg 7 25
1831