Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
8200 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona

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

Post correlati Risposte Visualizzazioni Attività
1
ago 22
4036
1
giu 20
3175
2
mag 25
2811
0
ago 23
1921
1
feb 22
8643