跳至内容
菜单
此问题已终结


I want to bring the total value of the invoice to the stock.picking using the origin to bring it right I tried to do something else, it did not work can you help me?

from odoo import api, fields, models, _ from odoo.exceptions import UserError



class StockPicking(models.Model):

    _inherit = 'stock.picking'


    def get_x_total(self):

        current_total = self.env['account.invoice'].search([('origin','=',self.origin)])

        x_total = current_total.('account.invoice').amount_total


        return x_total


    x_amout_total = fields.Float('Valor Total', default=lambda self: self.get_x_total())

形象
丢弃
最佳答案

Origin its a charlar field. Its editable so its bot the best option to make a search.

I would set a compute field, instead of default. But anyways I think its not working because of this line:

x_total = current_total.('account.invoice').amount_total

Try:

x_total = current_total.amount_total
形象
丢弃
编写者 最佳答案

Consegui usando o seguinte cod

class StockPicking(models.Model):

    _inherit = 'stock.picking'


'''FUNCAO PARA PEGAR DENTRO DO ACCOUNT.INVOICE O VALOR TOTAL DA FATURA E JOGAR DENTRO DA VARIAVEL X_AMOUNT_TOTAL 

(FUNCAO USADA PARA PODER COLOCAR VALOR DA FATURA DENTRO DO RELATORIO DE NOTA DE ENTREGA'''

    @api.one

    @api.depends('priority')

    def get_x_total(self):

        invoice = self.env['account.invoice'].search([('origin','=',self.origin)])

        x_total_valor = sum(line.amount_total for line in invoice)

        self.x_amount_total = x_total_valor


    x_amount_total = fields.Float(string='Valor da Fatura', compute='get_x_total',store=True)

形象
丢弃
相关帖文 回复 查看 活动
3
3月 15
4880
3
11月 24
3487
3
12月 22
6203
0
10月 22
2446
1
11月 19
4539