python - odoo10如何继承其他功能并更新线路?

标签 python odoo

现在我正在尝试购买模块上的代码 我是否想修改采购订单的计算?

这段代码是关于计算的。

@api.depends('order_line.price_total')
def _amount_all(self):
    for order in self:
        amount_untaxed = amount_tax = 0.0
        for line in order.order_line:
            amount_untaxed += line.price_subtotal
            # FORWARDPORT UP TO 10.0
            if order.company_id.tax_calculation_rounding_method == 'round_globally':
                taxes = line.taxes_id.compute_all(line.price_unit, line.order_id.currency_id, line.product_qty, product=line.product_id, partner=line.order_id.partner_id)
                amount_tax += sum(t.get('amount', 0.0) for t in taxes.get('taxes', []))
            else:
                amount_tax += line.price_tax
        order.update({
            'amount_untaxed': order.currency_id.round(amount_untaxed),
            'amount_tax': order.currency_id.round(amount_tax),
            'amount_total': amount_untaxed + amount_tax,
        }) 

这是我的模块,用于继承该代码。

class PurchaseOrderNew(models.Model):
    _inherit = "purchase.order.line"

    new_currency = fields.Float()

 def _amount_all(self):
    res = super(PurchaseOrderLine, self)_amount_all()

       #### i don't have no idea how to let 'new_currency' to  
     #### multiple with amount_total in order.update

    return res 

有人对此有想法吗?
我只想 order.update 中的 new_currency 是 amount_total 的倍数。
[ 新货币 * 金额总计 ]
但不知道如何编写这样的函数。

最佳答案

请尝试以下代码

def _amount_all(self):
    res = super(PurchaseOrderLine, self)_amount_all()
    for record in self:
       record.amount_total = self.new_currency*(amount_untaxed + amount_tax)
    return res 

如果您不想交税,可以保留该税

 def _amount_all(self):
     res = super(PurchaseOrderLine, self)_amount_all()
     for record in self:
         record.amount_total = self.new_currency*amount_untaxed
     return res

关于python - odoo10如何继承其他功能并更新线路?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54339043/

相关文章:

python - 填充文本未对齐

database - Odoo 数据库登录问题?

odoo - 我如何增加选择字段 "Selection Options "的大小

python - 刷新或检测 conda 环境

python - odoo中以下情况如何添加相关字段?

python - 如何从自定义模块在 Odoo 中创建库存变动?

python - Odoo - 解析错误 : "ValidateError Field(s) ` arch` failed against a constraint: Invalid view definition

python - 无法导入安装有 `pip install -e .` 的本地包

python - Numpy:智能矩阵乘法到稀疏结果矩阵

python - 我的问答游戏中的draw()函数无法正常工作