跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • 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. OPENERP 销售invoice(无税) 源码分析

OPENERP 销售invoice(无税) 源码分析

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

    接上贴 点击SO003的 创建发票 按钮
    [attach]477[/attach]
    [attach]478[/attach]
    [attach]479[/attach]

    [attach]480[/attach]

    [attach]481[/attach]

    [attach]482[/attach]

    [attach]483[/attach]

    [attach]484[/attach]

    [attach]497[/attach]
    更确切的说是 1 计算发票的付款到期日 2 生成会计凭证 3 更新 发票/会计凭证/会计分录 的编号 4 更改发票的状态为 OPEN
    这里面的第一个 方法
    def action_date_assign(self, cr, uid, ids, *args):
    for inv in self.browse(cr, uid, ids):
    res = self.onchange_payment_term_date_invoice(cr, uid, inv.id, inv.payment_term.id, inv.date_invoice)
    if res and res['value']:
    self.write(cr, uid, [inv.id], res['value'])
    return True
    作用就是计算付款到期日,根据付款规则计算付款到期日

    这里面的第二个方法 是这里的核心方法 放在最后说明

    这里面的第三个方法
    def action_number(self, cr, uid, ids, *args):
    cr.execute('SELECT id, type, number, move_id, reference '
    'FROM account_invoice '
    'WHERE id IN ('+','.join(map(str,ids))+')')
    obj_inv = self.browse(cr, uid, ids)[0]
    for (id, invtype, number, move_id, reference) in cr.fetchall():
    if not number:
    if obj_inv.journal_id.invoice_sequence_id:
    sid = obj_inv.journal_id.invoice_sequence_id.id
    number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id=%s', {'fiscalyear_id': obj_inv.period_id.fiscalyear_id.id})
    else:
    number = self.pool.get('ir.sequence').get(cr, uid,
    'account.invoice.' + invtype)
    if invtype in ('in_invoice', 'in_refund'):
    ref = reference
    else:
    ref = self._convert_ref(cr, uid, number)
    cr.execute('UPDATE account_invoice SET number=%s '
    'WHERE id=%s', (number, id))
    cr.execute('UPDATE account_move SET ref=%s '
    'WHERE id=%s AND (ref is null OR ref = '')',
    (ref, move_id))
    cr.execute('UPDATE account_move_line SET ref=%s '
    'WHERE move_id=%s AND (ref is null OR ref = '')',
    (ref, move_id))
    cr.execute('UPDATE account_analytic_line SET ref=%s '
    'FROM account_move_line '
    'WHERE account_move_line.move_id = %s '
    'AND account_analytic_line.move_id = account_move_line.id',
    (ref, move_id))
    return True
    更新 发票/会计凭证/会计分录 的编号

    在介绍第二个方法时 先说明一下它用到的一些方法
    [attach]498[/attach]

    [attach]499[/attach]

    现在到终于到第三个方法了
    [attach]500[/attach]
    [attach]501[/attach]
    [attach]502[/attach]
    [attach]503[/attach]
    [attach]504[/attach]

               [color=Red] total[/color] += i['price']
                [color=Magenta]i['price'] = - i['price'][/color]
    和 
                iml.append({
                    'type': 'dest',
                    'name': name,
                    '[color=Magenta]price[/color]'[color=Red]: total,[/color]
                    'account_id': acc_id,
                    'date_maturity' : inv.date_due or False,
                    'amount_currency': diff_currency_p 
                            and total_currency or False,
                    'currency_id': diff_currency_p 
                            and inv.currency_id.id or False,
                    'ref': ref
            })
                 这个就是 影响 debit 和 credit 
            'debit':x['[color=Magenta]price[/color]']>0 and x['[color=Magenta]price[/color]'],
            'credit':x['[color=Magenta]price[/color]']<0 and -x['[color=Magenta]price[/color]'],
    

    菜终于上来了 可以开动了 点击 创建 发票的按钮
    [attach]505[/attach]
    11

    [[i] 本帖最后由 leetaizhu 于 2010-3-31 15:20 编辑 [/i]]

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

      嗯. 好复杂的...

      赞一个先....

      1 条回复 最后回复
      0

      • 登录

      • 没有帐号? 注册

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