11<?xml version =' 1.0' encoding =' UTF-8' ?>
22<odoo >
3- <record id =" industry_harvest_and_transfer_server_action" model =" ir.actions.server" >
4- <field name =" code" ><![CDATA[ dest_location = env['stock.location'].search([('complete_name', '=', 'WH/Stock')], limit=1)
5- if not dest_location:
6- raise UserError("Destination location not found (WH/Stock).")
7-
8- # Confirm harvest
9- record.action_confirm()
10-
11- # Match inputs and set as done
12- record['qty_producing'] = record.product_qty
13- record.action_generate_serial()
14- record.button_mark_done()
15-
16- # Create a picking
17- picking = env['stock.picking'].create({
18- 'picking_type_id': env.ref('stock.picking_type_internal').id,
19- 'location_id': record.location_dest_id.id,
20- 'location_dest_id': dest_location.id,
21- 'origin': record.name,
22- 'move_type': 'direct',
23- })
24-
25- # Add stock moves for the finished products
26- for move in record.move_finished_ids.filtered(lambda m: m.product_id.type == 'product'):
27- env['stock.move'].create({
28- 'name': move.product_id.display_name,
29- 'product_id': move.product_id.id,
30- 'product_uom_qty': move.quantity_done,
31- 'product_uom': move.product_uom.id,
32- 'location_id': record.location_dest_id.id,
33- 'location_dest_id': dest_location.id,
34- 'picking_id': picking.id,
35- })
36-
37- # Confirm, assign and validate the picking
38- picking.action_confirm()
39- picking.action_assign()
40- picking.button_validate()
41-
42-
43- ]]> </field >
44- <field name =" model_id" ref =" mrp.model_mrp_production" />
45- <field name =" state" >code</field >
46- <field name =" name" >Harvest and transfer</field >
47- <field name =" usage" >base_automation</field >
48- </record >
493 <record id =" industry_check_harvest_is_from_harvest_location_server_action" model =" ir.actions.server" >
50- <field name =" code" ><![CDATA[ if record.picking_type_id.x_is_harvest and not record.location_id.x_harvest_location:
51- raise UserError ("Source location shall be eligible for harvest.")]]> </field >
52- <field name =" model_id" ref =" stock.model_stock_picking" />
53- <field name =" state" >code</field >
544 <field name =" name" >Check Harvest Is From Harvest Location</field >
5+ <field name =" model_id" ref =" stock.model_stock_picking" />
556 <field name =" usage" >base_automation</field >
7+ <field name =" state" >code</field >
8+ <field name =" code" ><![CDATA[ if record.picking_type_id.x_is_harvest and not record.location_id.x_is_harvest:
9+ raise UserError ("Source location shall be eligible for harvest.")]]> </field >
5610 </record >
5711 <record id =" industry_create_lot_on_validation_server_action" model =" ir.actions.server" >
12+ <field name =" name" >Action for Assign Serial</field >
13+ <field name =" model_id" ref =" stock.model_stock_picking" />
14+ <field name =" usage" >base_automation</field >
15+ <field name =" state" >code</field >
5816 <field name =" code" ><![CDATA[
5917for picking in records:
6018 for ml in picking.move_line_ids:
6119 product = ml.product_id
62-
6320 if not product or product.tracking != 'lot':
6421 continue
65-
6622 if not ml.lot_id:
6723 serial = env['ir.sequence'].next_by_code('auto.lot.serial')
6824 lot = env['stock.lot'].create({
@@ -72,36 +28,5 @@ for picking in records:
7228 })
7329 ml.write({'lot_id': lot.id})
7430 ]]> </field >
75- <!-- <field name="code"><![CDATA[
76- generated_serial = env['ir.sequence'].next_by_code('auto.lot.serial')
77- prefix = generated_serial.split('-')[0] + '-'
78- existing_lots = set(
79- env['stock.lot'].search([
80- ('name', 'like', prefix + '%')
81- ]).mapped('name')
82- )
83-
84- for picking in records:
85- for ml in picking.move_line_ids:
86- product = ml.product_id
87- if not product or product.tracking != 'lot':
88- continue
89-
90- if not ml.lot_id:
91- serial = generated_serial
92- while serial in existing_lots:
93- serial = env['ir.sequence'].next_by_code('auto.lot.serial')
94-
95- lot = env['stock.lot'].create({
96- 'name': serial,
97- 'product_id': product.id,
98- 'company_id': picking.company_id.id,
99- })
100- ml.write({'lot_id': lot.id})
101- ]]></field> -->
102- <field name =" model_id" ref =" stock.model_stock_picking" />
103- <field name =" state" >code</field >
104- <field name =" name" >Action for Assign Serial</field >
105- <field name =" usage" >base_automation</field >
10631 </record >
10732</odoo >
0 commit comments