Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

How to set value when create stock picking via confirming a sale order?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
stock_pickingsale.orderOdoo13.0
2 Respostes
4273 Vistes
Avatar
Manuel González

When I confirm an order (sale.order) then it creates a stock.picking related to this order (when I confirm the sale order). I have a new field "insurance" at stock.picking which is filled when I select a carrier and then sums values of all lines excluding shipping and puts it in this field. I launch this with an @api_onchange method related to the carrier_id of the stock.picking


I want to directly set this value when stock.picking is created (when confirm an order clicking in Confirm button). How can I do this? I didn't find where the stock.picking is being created.


I'm using OCA delivery carrier branch and odoo v13

0
Avatar
Descartar
Avatar
Manuel González
Autor Best Answer

I finally did it work. I inherit sale.order and here I overwrite action_confirm method. Then I search inside self.picking_ids and here I can sum all lines excluding shipping method.

I'm not sure why picking doesn't exists if I try the solution proposed by Hamrul, but this works fine.

    def action_confirm(self):
        res = super(SaleOrder, self).action_confirm()
        self.ensure_one()
        for rec in self.picking_ids:
            # only if carrier is ups and have insurance
            if rec.carrier_id.delivery_type == "ups" and rec.carrier_id.ups_insurance:
                ups_insurance = rec.carrier_id.ups_insurance
                ups_insurance_value = sum(
                    sl.price_subtotal # value untaxed to sum
                    for ml in rec.move_lines
                    for sl in ml.sale_line_id
                    if "UPS" not in sl.name # if line name doesn't contain "UPS" in capital letters
                )
                rec.ups_insurance = ups_insurance,
                rec.ups_insurance_value = ups_insurance_value

        return res
0
Avatar
Descartar
Avatar
Kamrul Hasan
Best Answer

You need to inherit confirm button action and write to your new field "insurance" on stock.picking model via carrier_id.

def action_confirm(self):
for rec in self:
rec.carrier_id.write({'insurance': self.insurance})
return super([Class_name], self).action_confirm()


0
Avatar
Descartar
Manuel González
Autor


Manuel González
hace 2 segundos Autor

It doesn't work. It never goes inside the for loop. I guess in this point stock.picking is still void or something like that.
If I print self I get stock.picking() but it doesn't print anything inside the for loop.

def action_confirm(self):
import logging
_logger = logging.getLogger(__name__)
res = super(StockPicking, self).action_confirm()
_logger.critical(self) #it prints 'stock.picking()'
for rec in self:
_logger.critical('hello') #print nothing
_logger.critical(rec) #print nothing
[...]

Kamrul Hasan

when you click confirm button as excepted result 'stock.picking(11,)' not 'stock.picking()'', please make sure function inherit right way.

Manuel González
Autor

The inherited function is done correctly, as far as I can see, it has declared the inheritance of stock.picking.

class StockPicking(models.Model):
_inherit = "stock.picking"

and I get the result I showed you before inside the action_confirm function.

I guess to make work this i should make inheritance with sale.order and, in the action_confirm function, iterate the self.picking_ids to find the pickings and work with them?

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
How to attach programmaticly pdf file/s into stock.picking
stock_picking sale.order
Avatar
0
de jul. 16
4140
How can I see where a product or a serial/lot number are reserved? Solved
stock stock_picking sale.order
Avatar
Avatar
1
de juny 22
6234
How to obtain the serial number of a product from a sales order?
serial_number sale.order Odoo13.0 rma
Avatar
0
de juny 24
1557
inherit stock.picking
community stock_picking sale.order v15
Avatar
Avatar
1
de març 24
3659
How to validate delivery order forcefully in Odoo 13? Solved
sale.order picking_out Odoo13.0 odoo13CE
Avatar
Avatar
1
de juny 22
3035
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now