Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
8253 Vues

In our Company the FIRST step we complete is the creation of the SERIAL NUMBER or LOT NUMBER and create a Label that we can print and affix to the frame of our finished product.

The Manufacturing App works by not asking for the number until the END of the order.

How can we address this?

Avatar
Ignorer
Meilleure réponse

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):



Avatar
Ignorer

Dear ray,

I tried this solution on online version it worked like a charm. However, in odoo v12 its not working. I see lot label button on the bottom of the page when I click it the buttons get disabled. Where am I going wrong? Kindly assist

Publications associées Réponses Vues Activité
1
août 22
4063
1
juin 20
3197
2
mai 25
2850
0
août 23
1944
1
févr. 22
8723