I've managed to create a transfer (stock.picking) record and, through setting the Stock Moves field in the transfer, a stock.move record.
The trouble is that, despite the stock.move being created as a field in the stock.picking record, the two resulting records appear to be unrelated:
• The Transfer record has nothing in its move lines
• The Stock Move record has "Stock Rule/External ID" = FALSE
Below is are details of the current Automated Action setup. Any advice/guidance/resource-links would be greatly appreciated:
I create a new automated action with the following settings:
- Action To Do: Create a new Record
- Create/Write Target Model: Transfer
Under the "Data to Write", I have the following:
FIELD (stock.picking) |
EVALUATION TYPE |
Record / Value |
Company |
Reference |
MyCompany |
Source Location |
Reference |
WH/Input |
Destination Location |
Reference |
WH/Scrap |
Operation Type |
Reference |
MyCompany: Internal Transfer |
Source Document |
Python expression |
record.x_name |
Qty |
Python expression |
record.x_studio_quantity_rejected |
Product |
Python expression |
record.x_studio_product.id |
Stock Moves |
Python expression |
env['stock.move'].create({ 'name': 'Rejected Product Transfer', 'location_id': 14, 'location_dest_id': 20, 'product_id': record.x_studio_product.id, 'product_uom': 1, 'product_uom_qty': record.x_studio_quantity_rejected, 'procure_method': 'make_to_stock', 'date_expected': datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'date': datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'company_id': 1, }) |
As I say, this successfully creates both a new transfer, and a new stock move record. But, like I say, despite the stock.move being created as a field in the stock.picking record, the two records appear to be unrelated:
• The Transfer record has nothing in its move lines
• The Stock Move record has "Stock Rule/External ID" = FALSE
(Odoo v12 Enterprise)
Did you manage to find a solution for this?
Unfortunately, no. Experimented a bit more, but never found a solution. Ultimately I gave up.
Would still be really nice to know how to accomplish this though... ;)