mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
update paid
This commit is contained in:
10
app_base_chinese/models/__init__.py
Normal file
10
app_base_chinese/models/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import res_partner
|
||||
from . import res_currency
|
||||
from . import product_category
|
||||
from . import stock_location
|
||||
from . import account_tax_group
|
||||
|
||||
|
||||
|
||||
9
app_base_chinese/models/account_tax_group.py
Normal file
9
app_base_chinese/models/account_tax_group.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import api, fields, models, _, tools
|
||||
|
||||
class AccountTaxGroup(models.Model):
|
||||
_inherit = 'account.tax.group'
|
||||
|
||||
active = fields.Boolean(default=True, help="Set active to false to hide the tax without removing it.")
|
||||
|
||||
14
app_base_chinese/models/product_category.py
Normal file
14
app_base_chinese/models/product_category.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class ProductCategory(models.Model):
|
||||
_inherit = "product.category"
|
||||
|
||||
complete_name = fields.Char(
|
||||
'Complete Name', compute='_compute_complete_name',
|
||||
store=True, translate=True)
|
||||
17
app_base_chinese/models/res_company.py
Normal file
17
app_base_chinese/models/res_company.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import api, models, fields, _
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
short_name = fields.Char('Short Name', related='partner_id.short_name', readonly=False)
|
||||
|
||||
# 当传参 show_short_company 时,只显示简称
|
||||
def name_get(self):
|
||||
if self._context.get('show_short_company'):
|
||||
return [(value.id, "%s" % (value.short_name if value.short_name else value.name)) for value in self]
|
||||
else:
|
||||
return super().name_get()
|
||||
11
app_base_chinese/models/res_country.py
Normal file
11
app_base_chinese/models/res_country.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class Country(models.Model):
|
||||
_inherit = 'res.country'
|
||||
_order = 'sequence,name'
|
||||
|
||||
sequence = fields.Integer('Sequence', help="Determine the display order", default=99)
|
||||
53
app_base_chinese/models/res_currency.py
Normal file
53
app_base_chinese/models/res_currency.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ResCurrency(models.Model):
|
||||
_inherit = 'res.currency'
|
||||
_order = 'active desc, sequence, name'
|
||||
|
||||
sequence = fields.Integer('Sequence', default=10, help="Determine the display order. Sort ascending.")
|
||||
|
||||
def rmb_upper(self, value):
|
||||
"""
|
||||
人民币大写
|
||||
传入浮点类型的值返回 unicode 字符串
|
||||
:param 传入阿拉伯数字
|
||||
:return 返回值是对应阿拉伯数字的绝对值的中文数字
|
||||
"""
|
||||
if self.name != 'CNY':
|
||||
return
|
||||
rmbmap = [u"零", u"壹", u"贰", u"叁", u"肆", u"伍", u"陆", u"柒", u"捌", u"玖"]
|
||||
unit = [u"分", u"角", u"元", u"拾", u"佰", u"仟", u"万", u"拾", u"佰", u"仟", u"亿",
|
||||
u"拾", u"佰", u"仟", u"万", u"拾", u"佰", u"仟", u"兆"]
|
||||
# 冲红负数处理
|
||||
xflag = 0
|
||||
if value < 0:
|
||||
xflag = value
|
||||
value = abs(value)
|
||||
# 先把value 数字进行格式化保留两位小数,转成字符串然后去除小数点
|
||||
nums = list(map(int, list(str('%0.2f' % value).replace('.', ''))))
|
||||
words = []
|
||||
zflag = 0 # 标记连续0次数,以删除万字,或适时插入零字
|
||||
start = len(nums) - 3
|
||||
for i in range(start, -3, -1): # 使i对应实际位数,负数为角分
|
||||
# 大部分情况对应数字不等于零 或者是刚开始循环
|
||||
if 0 != nums[start - i] or len(words) == 0:
|
||||
if zflag:
|
||||
words.append(rmbmap[0])
|
||||
zflag = 0
|
||||
words.append(rmbmap[nums[start - i]]) # 数字对应的中文字符
|
||||
words.append(unit[i + 2]) # 列表此位置的单位
|
||||
# 控制‘万/元’ 万和元比较特殊,如2拾万和2拾1万 无论有没有这个1 万字是必须的
|
||||
elif 0 == i or (0 == i % 4 and zflag < 3):
|
||||
# 上面那种情况定义了 2拾1万 的显示 这个是特殊对待的 2拾万(一类)的显示
|
||||
words.append(unit[i + 2])
|
||||
# 元(控制条件为 0 == i )和万(控制条为(0 == i % 4 and zflag < 3))的情况的处理是一样的
|
||||
zflag = 0
|
||||
else:
|
||||
zflag += 1
|
||||
if words[-1] != unit[0]: # 结尾非‘分’补整字 最小单位 如果最后一个字符不是最小单位(分)则要加一个整字
|
||||
words.append(u"整")
|
||||
if xflag < 0: # 如果为负数则要在数字前面加上‘负’字
|
||||
words.insert(0, u"负")
|
||||
return ''.join(words)
|
||||
33
app_base_chinese/models/res_partner.py
Normal file
33
app_base_chinese/models/res_partner.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import api, models, fields, _
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
name = fields.Char(index=True, translate=True)
|
||||
short_name = fields.Char('Short Name') # 简称
|
||||
fax = fields.Char('Fax') # 简称
|
||||
|
||||
# 增加地址显示中的手机号与电话号码
|
||||
# 选项 show_address 开启则增加显示手机与电话号
|
||||
def _get_name(self):
|
||||
name = super(ResPartner, self)._get_name() or ''
|
||||
partner = self
|
||||
if self._context.get('show_address'):
|
||||
if partner.mobile and partner.phone:
|
||||
name = name + "\n" + partner.mobile + "," + partner.phone
|
||||
elif partner.mobile:
|
||||
name = name + "\n" + partner.mobile
|
||||
elif partner.phone:
|
||||
name = name + "\n" + partner.phone
|
||||
return name
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
for values in vals_list:
|
||||
if 'lang' not in values:
|
||||
values['lang'] = 'zh_CN'
|
||||
return super(ResPartner, self).create(vals_list)
|
||||
12
app_base_chinese/models/stock_location.py
Normal file
12
app_base_chinese/models/stock_location.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class Location(models.Model):
|
||||
_inherit = "stock.location"
|
||||
|
||||
complete_name = fields.Char("Full Location Name", compute='_compute_complete_name', store=True, translate=True)
|
||||
Reference in New Issue
Block a user