仰天大笑出门去,我辈岂是蓬蒿人。这篇文章主要讲述odoo中的mapped相关的知识,希望能为你提供帮助。
def _mapped_func(self, func): """ Apply function ``func`` on all records in ``self``, and return the result as a list or a recordset (if ``func`` returns recordsets). """ if self: vals = [func(rec) for rec in self] if isinstance(vals[0], BaseModel): return vals[0].union(*vals)# union of all recordsets return vals else: vals = func(self) return vals if isinstance(vals, BaseModel) else []def mapped(self, func): """ Apply ``func`` on all records in ``self``, and return the result as a list or a recordset (if ``func`` return recordsets). In the latter case, the order of the returned recordset is arbitrary.:param func: a function or a dot-separated sequence of field names (string); any falsy value simply returns the recordset ``self`` """ if not func: return self# support for an empty path of fields if isinstance(func, str): recs = self for name in func.split(‘.‘): recs = recs._mapped_func(operator.itemgetter(name)) return recs else: return self._mapped_func(func)
【odoo中的mapped】
self_datetime = max(self.invoice_line_ids.mapped(‘write_date‘))
func = operator.itemgetter(name) // 获取对象的name值的方法
func(rec) 获取rec的write_date值
推荐阅读
- cordova+vue-cli4构建app
- uni-app微信小程序入门
- 德比足球_德比APP_皇马靠防守追平巴萨
- Mac使用安卓模拟器-网易MuMu
- Android短视频滑动播放
- 使用Android Studio创建Andorid模拟器
- Android中使用SeekBar拖动条实现改变图片透明度
- Python模拟测试权威入门
- Elasticsearch Ruby on Rails(Chewy Gem教程)