تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
3696 أدوات العرض


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
مارس 15
4882
3
نوفمبر 24
3504
3
ديسمبر 22
6207
0
أكتوبر 22
2450
1
نوفمبر 19
4542