mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
update common
This commit is contained in:
@@ -147,7 +147,7 @@
|
|||||||
<xpath expr="//templates" position="before">
|
<xpath expr="//templates" position="before">
|
||||||
<field name="credit_limit"/>
|
<field name="credit_limit"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//div[@class='oe_kanban_details']/ul" position="inside">
|
<xpath expr="//div[hasclass('oe_kanban_details')]/ul" position="inside">
|
||||||
<li t-if="record.credit_limit and record.credit_limit.raw_value">
|
<li t-if="record.credit_limit and record.credit_limit.raw_value">
|
||||||
Credit:<field name="credit_limit"/>
|
Credit:<field name="credit_limit"/>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -22,4 +22,4 @@
|
|||||||
# http://www.sunpop.cn/odoo10_developer_document_offline/
|
# http://www.sunpop.cn/odoo10_developer_document_offline/
|
||||||
# description:
|
# description:
|
||||||
|
|
||||||
from . import models
|
from . import base
|
||||||
|
|||||||
16
app_common/models/base.py
Normal file
16
app_common/models/base.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from odoo import models, fields, api, _
|
||||||
|
|
||||||
|
|
||||||
|
class Base(models.AbstractModel):
|
||||||
|
_inherit = 'base'
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _app_get_m2o_default(self, fieldname, domain=[]):
|
||||||
|
if hasattr(self, fieldname) and self._fields[fieldname].type == 'many2one':
|
||||||
|
if self._context.get(fieldname) or self._context.get('default_%s' % fieldname):
|
||||||
|
return self._context.get(fieldname) or self._context.get('default_%s' % fieldname)
|
||||||
|
else:
|
||||||
|
rec = self.env[self._fields[fieldname].comodel_name].search(domain, limit=1)
|
||||||
|
return rec.id if rec else False
|
||||||
|
return False
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
from odoo import models, fields, api, _
|
|
||||||
|
|
||||||
|
|
||||||
class BaseModelExtend(models.AbstractModel):
|
|
||||||
_name = 'basemodel.extend'
|
|
||||||
_description = 'Base Extend for Sunpop'
|
|
||||||
|
|
||||||
def _register_hook(self):
|
|
||||||
'''
|
|
||||||
Register method in BaseModel
|
|
||||||
如果 该 fieldname 是m2o的,那么如果context没值,就用该模型第一个
|
|
||||||
'''
|
|
||||||
@api.model
|
|
||||||
def _app_get_m2o_default(self, fieldname):
|
|
||||||
if hasattr(self, fieldname) and self._fields[fieldname].type == 'many2one':
|
|
||||||
if self._context.get(fieldname) or self._context.get('default_%s' % fieldname):
|
|
||||||
return self._context.get(fieldname) or self._context.get('default_%s' % fieldname)
|
|
||||||
else:
|
|
||||||
rec = self.env[self._fields[fieldname].comodel_name].search([], limit=1)
|
|
||||||
return rec.id if rec else False
|
|
||||||
return False
|
|
||||||
|
|
||||||
models.BaseModel._app_get_default = _app_get_m2o_default
|
|
||||||
return super(BaseModelExtend, self)._register_hook()
|
|
||||||
Reference in New Issue
Block a user