I add a customized class into sale.py, but it never work irrespective of whether i upgrade apps, restart odoo or unstall and then install.
In the Technical/Databasee structure/Models/Sales Order/Fields, I cant find out my customized Field( amount_in_words and amount_in_figures ) .
So i am wonder how to make it work?
Here's my code.(update)
part 1:
class SaleOrder(models.Model):
_name = "sale.order"
_inherit = ['portal.mixin', 'mail.thread', 'mail.activity.mixin', 'utm.mixin']
_description = "Sales Order"
_order = 'date_order desc, id desc'
_check_company_auto = True
def num2chn(self):
numchar = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
pr = ['圆', '拾', '佰', '仟', '萬', '拾']
total = int(self.amount_total)
length = len(str(total))
chn = ''
for i in str(total):
length -= 1
chn = chn + ('%s%s' % (numchar[int(i)], pr[length]))
return chn
part2:amount_chn = fields.Text(string='大写金额', readonly=True)
name = fields.Char(string='Order Reference', required=True, copy=False, readonly=True, states={'draft': [('readonly', False)]}, index=True, default=lambda self: _('New'))
origin = fields.Char(string='Source Document', help="Reference of the document that generated this sales order request.")
client_order_ref = fields.Char(string='Customer Reference', copy=False)
part 3
@api.model
def create(self, vals):
if vals.get('name', _('New')) == _('New'):
seq_date = None
.........
vals['pricelist_id'] = vals.setdefault('pricelist_id', partner.property_product_pricelist and partner.property_product_pricelist.id)
vals['amount_chn'] = self.num2chn(vals['amount_total']) #just add one row code here.
result = super(SaleOrder, self).create(vals)
return result