1. Add a new custom field to the Manufacturing Order.
2. Add a new button that auto populates the next available number and then generates the same PDF you would get if you printed from the LOT record.
3. Pass the new LOT number to the Production Wizard so the user doesn't have to create and/or select it there.
Steps:
1. Add a new custom field to the Manufacturing Order.
Add to the Database:
Add to the User Interface:
<xpath expr="//field[@name='bom_id']" position="before">
<field name="x_new_lot" string="Lot Label"
attrs="{'invisible': [('x_new_lot','=',False)]}"/>
</xpath>
2. Add a new button that auto populates the next available number and
then generates the same PDF you would get if you printed from the LOT
record.
Create the Button:
Code for the button:
if not record.x_new_lot:
record['x_new_lot'] = env['stock.production.lot'].create({'company_id': 1,'product_id': record.product_id.id})
action = env.ref('stock.action_report_lot_label').report_action(record.x_new_lot)
Add the Button to the User Interface:
<button name="button_unplan" position="after">
<button name="535" type="action" string="LOT LABEL" class="oe_highlight"
attrs="{'invisible': ['|','|',('state','=','cancel'),
('x_new_lot','!=',False),
('product_id','=',False)]}"/>
</button>
3. Pass the new LOT number to the Production Wizard so the user doesn't have to create and/or select it there.
You have to do this TWICE, since the PRODUCE button is in the View twice:
<xpath expr="//form/header/button[@name='open_produce_product'][1]" position="attributes">
<attribute name="context">{'default_finished_lot_id': x_new_lot}</attribute>
</xpath>
<xpath expr="//form/header/button[@name='open_produce_product'][2]" position="attributes">
<attribute name="context">{'default_finished_lot_id': x_new_lot}</attribute>
</xpath>
Now you get this:
A. Before clicking the BUTTON:
B. After clicking the BUTTON:
C. When clicking PRODUCE:
(LOT automatically copied over to the PRODUCE Wizard):