Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Openerp 连接字符串和浮点_Openerp - Fatal编程技术网

Openerp 连接字符串和浮点

Openerp 连接字符串和浮点,openerp,Openerp,在openerp v7中,是否可以输出一笔在前面添加了欧元符号的金额 例如,如果我尝试,“€”+0.0它说我不能在字符串中附加浮点数。您可以使用monetary小部件轻松实现这一点。我们已经用了很久了 在python文件中: class your_class(orm.Model): _inherit = 'your.class' def _get_your_currency_id(self, cr, uid, ids, name, args, context=None):

在openerp v7中,是否可以输出一笔在前面添加了欧元符号的金额


例如,如果我尝试,
“€”+0.0
它说我不能在字符串中附加浮点数。

您可以使用monetary小部件轻松实现这一点。我们已经用了很久了

在python文件中:

class your_class(orm.Model):
    _inherit = 'your.class'

    def _get_your_currency_id(self, cr, uid, ids, name, args, context=None):
        res = {}
        for voucher in self.browse(cr, uid, ids, context=context):
            your_currency_id = self.pool.get('res.currency').search(cr, uid, [('name', '=', 'EUR')], context=context)
            if your_currency_id:
                res[voucher.id] = your_currency_id[0] 
        return res

    _columns = {
                'your_amount_field' :fields.float('Your Amount Field'),
                'your_currency_id': fields.function(_get_your_currency_id, type='many2one', relation='res.currency', string='Currency', readonly=True, required=True),
                }
在xml文件中:

<field name="your_currency_id" invisible="1" />
<field name="your_amount_field" class="oe_inline" string="Test Amount" widget="monetary" options="{'currency_field': 'your_currency_id'}" />

从技术上讲,它所做的是,我们已经在表中列出了一组所有可能可用的国家货币,称为res\u currency


我们只是在搜索欧元,让monetary widget使用选项字典来使用搜索到的特定欧元。其余部分将由小部件本身处理。

您可以使用monetary小部件轻松完成。我们已经用了很久了

在python文件中:

class your_class(orm.Model):
    _inherit = 'your.class'

    def _get_your_currency_id(self, cr, uid, ids, name, args, context=None):
        res = {}
        for voucher in self.browse(cr, uid, ids, context=context):
            your_currency_id = self.pool.get('res.currency').search(cr, uid, [('name', '=', 'EUR')], context=context)
            if your_currency_id:
                res[voucher.id] = your_currency_id[0] 
        return res

    _columns = {
                'your_amount_field' :fields.float('Your Amount Field'),
                'your_currency_id': fields.function(_get_your_currency_id, type='many2one', relation='res.currency', string='Currency', readonly=True, required=True),
                }
在xml文件中:

<field name="your_currency_id" invisible="1" />
<field name="your_amount_field" class="oe_inline" string="Test Amount" widget="monetary" options="{'currency_field': 'your_currency_id'}" />

从技术上讲,它所做的是,我们已经在表中列出了一组所有可能可用的国家货币,称为res\u currency


我们只是在搜索欧元,让monetary widget使用选项字典来使用搜索到的特定欧元。其余部分将由小部件本身处理。

您可以使用monetary小部件轻松完成。我们已经用了很久了

在python文件中:

class your_class(orm.Model):
    _inherit = 'your.class'

    def _get_your_currency_id(self, cr, uid, ids, name, args, context=None):
        res = {}
        for voucher in self.browse(cr, uid, ids, context=context):
            your_currency_id = self.pool.get('res.currency').search(cr, uid, [('name', '=', 'EUR')], context=context)
            if your_currency_id:
                res[voucher.id] = your_currency_id[0] 
        return res

    _columns = {
                'your_amount_field' :fields.float('Your Amount Field'),
                'your_currency_id': fields.function(_get_your_currency_id, type='many2one', relation='res.currency', string='Currency', readonly=True, required=True),
                }
在xml文件中:

<field name="your_currency_id" invisible="1" />
<field name="your_amount_field" class="oe_inline" string="Test Amount" widget="monetary" options="{'currency_field': 'your_currency_id'}" />

从技术上讲,它所做的是,我们已经在表中列出了一组所有可能可用的国家货币,称为res\u currency


我们只是在搜索欧元,让monetary widget使用选项字典来使用搜索到的特定欧元。其余部分将由小部件本身处理。

您可以使用monetary小部件轻松完成。我们已经用了很久了

在python文件中:

class your_class(orm.Model):
    _inherit = 'your.class'

    def _get_your_currency_id(self, cr, uid, ids, name, args, context=None):
        res = {}
        for voucher in self.browse(cr, uid, ids, context=context):
            your_currency_id = self.pool.get('res.currency').search(cr, uid, [('name', '=', 'EUR')], context=context)
            if your_currency_id:
                res[voucher.id] = your_currency_id[0] 
        return res

    _columns = {
                'your_amount_field' :fields.float('Your Amount Field'),
                'your_currency_id': fields.function(_get_your_currency_id, type='many2one', relation='res.currency', string='Currency', readonly=True, required=True),
                }
在xml文件中:

<field name="your_currency_id" invisible="1" />
<field name="your_amount_field" class="oe_inline" string="Test Amount" widget="monetary" options="{'currency_field': 'your_currency_id'}" />

从技术上讲,它所做的是,我们已经在表中列出了一组所有可能可用的国家货币,称为res\u currency


我们只是在搜索欧元,让monetary widget使用选项字典来使用搜索到的特定欧元。其余部分将由小部件本身处理。

您只需将小部件添加到需要货币符号的金额字段中

<field name="your_field" widget="monetary" options="{'currency_field': 'currency_field_of_you_model'}"

您只需将小部件添加到需要货币符号的金额字段中

<field name="your_field" widget="monetary" options="{'currency_field': 'currency_field_of_you_model'}"

您只需将小部件添加到需要货币符号的金额字段中

<field name="your_field" widget="monetary" options="{'currency_field': 'currency_field_of_you_model'}"

您只需将小部件添加到需要货币符号的金额字段中

<field name="your_field" widget="monetary" options="{'currency_field': 'currency_field_of_you_model'}"