How the Delivery orders are created from Sale Orde

2020-07-22 17:52发布

问题:

In sale app, where are the inventory delivery orders created from sale order while confirming the quotations? What are the functions which are called during this workflow in ODOO10?

回答1:

Here is an useful trick I do when I am not able to follow the traceback.

You said you want to know where the delivery order is being created, don't you? So, as delivery order is an outgoing stock picking, you can write the following lines in your code:

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

    @api.model
    def create(self, vals):
        return 1 / 0

Now create a sale order and confirm it, this time you will obviously get an error. This error will show you the whole traceback, so you can read which methods are being called, and finally, the one you are trying to find, in my database, with my configuration, the guilty one is assign_picking, in the stock.move.py file of the stock module.

File "/my_odoo_path/addons/stock/models/stock_move.py", line 429, in assign_picking picking = Picking.create(move._get_new_picking_values())

Try it, and you will find the method you are looking for.



回答2:

Finally found where it is being created,

First while confirming a sale order, it creates a procurement order, then from the procurement it creates stock moves, and from the stock move it creates the whole stock.picking delivery order.

You can find the code of where the creation of a delivery order in:

stock-->procurement-->_get_stock_move_values.

Here all the values of initial demand and the main fields of stock.picking are passed and created.



标签: odoo odoo-10