0

I am using odoo 15 ; I am trying to customize receipt in point_of_sale module I have a problem regard access the custom filed in company module as following :

My customized module : custom/models/res_company.py

class rescompany(models.Model): 
   _name = "res.company"
   _inherit = "res.company"
 
   #customized fields
   
   x_industry = fields.Char(string='Compnay Industry', translate=True) 

my customized view in xml : custom/static/src/xml/custom_pos.xml

  <xpath expr="//t[@t-if='receipt.company.logo']"  position="before">
           
             <div>
                <span style="font-size: smaller;float: left">
                <t t-esc="receipt.company.name" />
                </span>
               
             </div>
             
             <div>
                <div>
                     <span style="font-size: smaller;float: left">
                        <t t-esc="receipt.company.x_industry"/>
                     </span>
                </div>
               
             </div>
       </xpath>

    </t>
</templates>

manifest.py

...
'assets': {
        'web.assets_backend': [
            "custom/static/src/js/OrderReceipt.js",
         ],
        'web.assets_qweb': [
            'custom/static/src/xml/custom_pos.xml',
        ],
    },
...

Now, I don't know how to access x_industry in OrderReceipt.js ? I tried to follow this link : Odoo PoS not showing custom fields in receipts but it is in odoo 13 and I did not understand the parameters I should add to be modified correctly ;

user1261494
  • 139
  • 1
  • 10

1 Answers1

0

You cannot access a field in PoS even though it has been added through python code. You need to load the specific field in the javascript files for Point of Sale.

Regarding your question, you need to add a field which is specific for a company. The easiest method is to also add the same field in pos.config model and give a related connection with the new field which you added in res.company.

x_industry = fields.Char(string='Compnay Industry', translate=True, related='company_id.x_industry')

Any field added in the pos.config can be accessed from the PoS and PoS receipt.

<t t-esc="env.pos.config.x_industry"/>
Mihran Thalhath
  • 325
  • 2
  • 10