美文网首页
Odoo10开发记录

Odoo10开发记录

作者: itrojan | 来源:发表于2016-11-11 16:26 被阅读354次

1、上传的文件保存路径根据启动的conf配置的data_dir目录下,系统迁移服务器的时候记得备份。


2、给H1增加label,<label for="name"/><field name="name"/>


3、设置—用户—群组:为每个应用程序划分级别,例如:经理、员工


4、开发完成的模块进行翻译,首先进入【设置—翻译—应用程序术语】,点击【同步术语】,执行完成之后进入【设置—翻译—应用程序术语—已翻译术语】搜索需要翻译的源术语,修改翻译值并保存。


5、设置—翻译—应用程序术语—已翻译术语 设置翻译
类型:字段、对象、报表/模板、选中内容、视图、帮助、代码、约束、SQL约束

  • 对象,翻译字段是模型名称+逗号+字段名(ir.ui.view,arch_db),翻译数据库中某个字段内的数据
  • 代码,翻译字段是一个文件的完整路径(addons/base/res/res_config.py),翻译某个文件中出现的文字,比如字段中help的内容、default的内容
  • 选中内容,翻译字段是模型名称+逗号+字段名(ir.translation,state),翻译Selection类型字段中的值
  • SQL约束,翻译字段是模型名称(res.country),翻译_sql_constraints内的错误提示内容

6、创建新模块
python odoo-bin scaffold goal D:\python\odoo10\addons


7、继承重写ir.actions.act_window不需要新的id,直接调用原id进行添加或修改

<record id="base.action_partner_supplier_form" model="ir.actions.act_window">
<field name="domain">[('supplier', '=', True)]</field>
</record>

8、title上删除“Odoo”修改以下文件
addons\web\static\src\js\abstract_web_client.js,54行

this.set('title_part', {"zopenerp": "Odoo"});

addons\web\views\webclient_templates.xml,198行

<title t-esc="title or 'Odoo'"/>

警告提示框删除odoo文字
addons\web\static\src\js\framework\crash_manager.js,第108行

title: "Odoo " + (_.str.capitalize(error.type) || _t("Warning"))

9、实时获取当前长时间、短时间

date = fields.Date(string=u'display_name', default=fields.Date.context_today, compute='_compute_dates', inverse='_inverse_dates', store=True, states={'done': [('readonly', True)]}, track_visibility='onchange')
datetime = fields.Datetime(string=u'display_name', default=fields.Datetime.now, readonly=True, copy=False, help='', compute='_methods_compute', store=True)
now = fields.Datetime.now()
date = fields.Date.today()

10、Selection类型字段继承扩展增加新选项

type = fields.Selection(selection_add=[('product', 'Stockable Product')])

11、通过代码跳转页面

@api.multi
    def action_invoice_sent(self):
        """ Open a window to compose an email, with the edi invoice template
            message loaded by default
        """
        self.ensure_one()
        template = self.env.ref('account.email_template_edi_invoice', False)
        compose_form = self.env.ref('mail.email_compose_message_wizard_form', False)
        ctx = dict(
            default_model='account.invoice',
            default_res_id=self.id,
            default_use_template=bool(template),
            default_template_id=template and template.id or False,
            default_composition_mode='comment',
            mark_invoice_as_sent=True,
            custom_layout="account.mail_template_data_notification_email_account_invoice"
        )
        return {
            'name': _('Compose Email'),
            'type': 'ir.actions.act_window',
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'mail.compose.message',
            'views': [(compose_form.id, 'form')],
            'view_id': compose_form.id,
            'target': 'new',
            'context': ctx,
        }

12、获取本地ip

myname = socket.getfqdn(socket.gethostname())
        myaddr = socket.gethostbyname(myname)
        print request.context
        print request.httprequest.remote_addr
        print myname, myaddr
        ipList = socket.gethostbyname_ex(socket.gethostname())
        for i in ipList:
            print i

相关文章

网友评论

      本文标题:Odoo10开发记录

      本文链接:https://www.haomeiwen.com/subject/ikffpttx.html