Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
3679 Visualizzazioni


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
Abbandona
Risposta migliore

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
Abbandona
Autore Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
3
mar 15
4877
3
nov 24
3476
3
dic 22
6202
0
ott 22
2444
1
nov 19
4533