Tuesday, October 1, 2019

cost amount by words in odoo

ODOO


 

python def

 

here we have cost amount money as number and we want to generate cost amount as words by using the number cost amount , and we can do it as bellow 
  • create the cost amount number field 
amount = fields.Float(string="Amount", required=True)
  • create the cost amount words field 
amount_words = fields.Float(string="Amount In Writting", readonly=True, compute='_onchange_amount') 

  • create get_amount_in_words function which will convert amount to words and store it in amount_words filed
@api.onchange('amount')
    def
_onchange_amount(self):
        context = self._context or {}
        if hasattr(super(ClassName, self), '_onchange_amount'):
            super(ClassName, self)._onchange_amount()
        if context.get('lang') == 'ar_SY':
            units_name = self.currency_id.currency_unit_label
            cents_name = self.currency_id.currency_subunit_label
            self.amount_words = amount_to_text_ar.amount_to_text(
                self.amount, 'ar', units_name, cents_name)

No comments:

Post a Comment

Odoo Invoice Qr code issues

There are two main issues must of us facing with the QR code in Odoo invoice & these issues are 1/ QR code displayed as broken image w...