跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(Flatly)
  • 不使用皮肤
折叠

Odoo 中文社区

  1. 主页
  2. 版块
  3. Odoo 开发与实施交流
  4. [代码分析] 财务报表中的部分变量是如何定义和赋值的?

[代码分析] 财务报表中的部分变量是如何定义和赋值的?

已定时 已固定 已锁定 已移动 Odoo 开发与实施交流
6 帖子 2 发布者 4.7k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • H 离线
    H 离线
    hifly
    写于 最后由 编辑
    #1

    [color=blue][u][size=10pt]account\report\common_report_header.py[/size][/u][/color]

    <br />import pooler<br />from tools.translate import _<br /><br />class common_report_header(object):<br /><br />&nbsp; &nbsp; def _sum_debit(self, period_id=False, journal_id=False):<br />&nbsp; &nbsp; &nbsp; &nbsp; if journal_id and isinstance(journal_id, int):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; journal_id = [journal_id]<br />&nbsp; &nbsp; &nbsp; &nbsp; if period_id and isinstance(period_id, int):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; period_id = [period_id]<br />&nbsp; &nbsp; &nbsp; &nbsp; if not journal_id:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; journal_id = self.journal_ids<br />&nbsp; &nbsp; &nbsp; &nbsp; if not period_id:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; period_id = self.period_ids<br />&nbsp; &nbsp; &nbsp; &nbsp; if not (period_id and journal_id):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0.0<br />&nbsp; &nbsp; &nbsp; &nbsp; self.cr.execute(&#039;SELECT SUM(debit) FROM account_move_line l &#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;WHERE period_id IN %s AND journal_id IN %s &#039; + self.query_get_clause + &#039; &#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (tuple(period_id), tuple(journal_id)))<br />&nbsp; &nbsp; &nbsp; &nbsp; return self.cr.fetchone()[0] or 0.0<br />
    


    找了半天,不知道 [color=red][b]self.journal_ids,self.period_ids,self.query_get_clause[/b][/color]这几个变量在哪里定义,其值从何而来。其子类,比如[color=blue][size=10pt][u]account_balance_sheet.py[/u][/size][/color]也没有找到定义。

    请大家帮忙分析一下,谢谢!

    1 条回复 最后回复
    0
    • mrshellyM 离线
      mrshellyM 离线
      mrshelly
      写于 最后由 编辑
      #2

      这只是一个class 的定义. 具体的 self.journal_ids 要看这个 class 的子class.

      EP:
      \addons\account\report\account_general_journal.py

      <br /><br />....<br />class journal_print(report_sxw.rml_parse, common_report_header):<br /><br />&nbsp; &nbsp; def __init__(self, cr, uid, name, context=None):<br />&nbsp; &nbsp; &nbsp; &nbsp; if context is None:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context = {}<br />&nbsp; &nbsp; &nbsp; &nbsp; super(journal_print, self).__init__(cr, uid, name, context=context)<br />&nbsp; &nbsp; &nbsp; &nbsp; self.period_ids = &#91;]<br />&nbsp; &nbsp; &nbsp; &nbsp; self.journal_ids = &#91;]<br />...<br />
      
      1 条回复 最后回复
      0
      • H 离线
        H 离线
        hifly
        写于 最后由 编辑
        #3

        Shelly, 你说的这个class的确查询到了上面提到的3个变量。

        但 同一目录下的account_profit_loss.py中

        <br />import time<br />import pooler<br />from report import report_sxw<br />from common_report_header import common_report_header<br />from tools.translate import _<br /><br />class report_pl_account_horizontal(report_sxw.rml_parse, common_report_header):<br /><br />&nbsp; &nbsp; def __init__(self, cr, uid, name, context=None):<br />&nbsp; &nbsp; &nbsp; &nbsp; super(report_pl_account_horizontal, self).__init__(cr, uid, name, context=context)<br />&nbsp; &nbsp; &nbsp; &nbsp; self.result_sum_dr = 0.0<br />&nbsp; &nbsp; &nbsp; &nbsp; self.result_sum_cr = 0.0<br />&nbsp; &nbsp; &nbsp; &nbsp; self.res_pl = {}<br />&nbsp; &nbsp; &nbsp; &nbsp; self.result = {}<br />&nbsp; &nbsp; &nbsp; &nbsp; self.result_temp = &#91;]<br />&nbsp; &nbsp; &nbsp; &nbsp; self.localcontext.update( {<br />
        


        和同一目录下的 account_balance_sheet.py中

        <br />import time<br />import pooler<br />from report import report_sxw<br />from account.report import account_profit_loss<br />from common_report_header import common_report_header<br />from tools.translate import _<br /><br />class report_balancesheet_horizontal(report_sxw.rml_parse, common_report_header):<br />&nbsp; &nbsp; def __init__(self, cr, uid, name, context=None):<br />&nbsp; &nbsp; &nbsp; &nbsp; super(report_balancesheet_horizontal, self).__init__(cr, uid, name, context=context)<br />&nbsp; &nbsp; &nbsp; &nbsp; self.obj_pl = account_profit_loss.report_pl_account_horizontal(cr, uid, name, context=context)<br />&nbsp; &nbsp; &nbsp; &nbsp; self.result_sum_dr = 0.0<br />&nbsp; &nbsp; &nbsp; &nbsp; self.result_sum_cr = 0.0<br />&nbsp; &nbsp; &nbsp; &nbsp; self.result = {}<br />&nbsp; &nbsp; &nbsp; &nbsp; self.res_bl = {}<br />&nbsp; &nbsp; &nbsp; &nbsp; self.result_temp = &#91;]<br />&nbsp; &nbsp; &nbsp; &nbsp; self.localcontext.update({<br />
        


        都没有查询到,不知道是怎么关联起来的。

        1 条回复 最后回复
        0
        • mrshellyM 离线
          mrshellyM 离线
          mrshelly
          写于 最后由 编辑
          #4

          如果 class A 里某个方法有个特别的变量


          而你 class B 继承于 class A 但不使用 class A里的那个方法.. 是不是不用管那个变量呢?

          仅供参考....

          1 条回复 最后回复
          0
          • H 离线
            H 离线
            hifly
            写于 最后由 编辑
            #5

            是的。
            被wizard窗口中的过滤字段误导了。
            大致过程应该是这样的:
            account\account.py

            <br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;balance&#039;: fields.function(__compute, digits_compute=dp.get_precision(&#039;Account&#039;), method=True, string=&#039;Balance&#039;, multi=&#039;balance&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;credit&#039;: fields.function(__compute, digits_compute=dp.get_precision(&#039;Account&#039;), method=True, string=&#039;Credit&#039;, multi=&#039;balance&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;debit&#039;: fields.function(__compute, digits_compute=dp.get_precision(&#039;Account&#039;), method=True, string=&#039;Debit&#039;, multi=&#039;balance&#039;),<br />
            


            在这个方法__compute里,层层调用才刚刚开始,多少明白一点了。
            谢谢Shelly, Jeff,继续往下看。。。

            1 条回复 最后回复
            0

            • 登录

            • 没有帐号? 注册

            • 登录或注册以进行搜索。
            • 第一个帖子
              最后一个帖子
            0
            • 版块
            • 标签
            • 热门
            • 用户
            • 群组