Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
682 Zobrazení

Hello from Germany :D

I'm trying to create my first Odoo model.

Create works and write does not work.

Thank you for your help!


from odoo import models, api


class PurchaseOrder(models.Model):

    _inherit = 'purchase.order'

    def button_confirm(self):

        res = super().button_confirm()


        for bestellung in self:

            lieferant = bestellung.partner_id


            for zeile in bestellung.order_line:

                produkt = zeile.product_id

                preis = zeile.price_unit

                waehrung = zeile.currency_id



                vorhandene_info = self.env['product.supplierinfo'].search([

                                                                            ('product_tmpl_id', '=', produkt.product_tmpl_id.id,),

                                                                            ('partner_id', '=', lieferant.id),

                                                                            ], limit=1)


                if vorhandene_info:

                    angebot = self.env['product.supplierinfo'].browse(vorhandene_info.id)

                    angebot.write({

                                    'price': preis,

                                    })

                else:

                    self.env['product.supplierinfo'].create({

                                                                'partner_id': lieferant.id,

                                                                'product_tmpl_id': produkt.product_tmpl_id.id,

                                                                'price': preis,

                                                                'min_qty': 1.0,

                                                                'currency_id':waehrung.id,

                                                                'delay':0

                                                            })

        self.flush()

        return res




Avatar
Zrušit
Autor Nejlepší odpověď

Thank you !

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
lis 24
12294
2
pro 23
2349
6
čvc 20
4276
1
dub 25
3941
2
kvě 20
6295