Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
2 Besvarelser
3671 Visninger


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())

Avatar
Kassér
Bedste svar

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
Avatar
Kassér
Forfatter Bedste svar

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)

Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
3
mar. 15
4862
3
nov. 24
3462
3
dec. 22
6200
0
okt. 22
2442
1
nov. 19
4532