I cant delete manufacturing order that am creating from my custom
model, in the view the order in draft state but i print the state of the
order in py that is in done state
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilidad
- Inventario
- PoS
- Project
- MRP
Se marcó esta pregunta
Hi,
This error occur when you not created the move_finished_ids in manufacturing order, this indicate that after the production to update the quantity of the produced product, that means move the product from production location to the particular warehouse,
To solve this you need to add move_finished_ids like this,
First you need to define the locations,
@api.model
def _get_default_location_type(self):
"""to get the default location"""
return self.env['stock.location'].search(
[('usage', '=', 'internal')], limit=1).id
@api.model
def _get_default_location_dest_type(self):
"""to get the default location"""
return self.env['stock.location'].search(
[('usage', '=', 'production')], limit=1).id
and then defined in a field
location_id = fields.Many2one('stock.location', string="From", required=True, domain=[('usage','=','internal')]",
default=_get_default_location_type)
location_dest_id = fields.Many2one('stock.location',
string="To", required=True,
domain="[('usage','=','production')]",
default=_get_default_location_dest_type)
Then create a manufacturing order
data = self.env['mrp.production'].create({
'product_id': self.product_id.id,
add required field here
})
and then write the move_fineshed_ids, please make sure that the location is correct, otherwise the quantity is note updated
data.write({
'move_finished_ids': [
(0, 0, {
'product_id': self.product_id.id,
'product_uom_qty': self.quantity,
'product_uom': self.units.id,
'location_id': self.location_id.id,
'location_dest_id': self.location_dest_id.id,
'name': self.product_id.name,
'warehouse_id':self.warehouse_id.id
})
]
})
Regards
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
InscribirsePublicaciones relacionadas | Respuestas | Vistas | Actividad | |
---|---|---|---|---|
|
2
ago 23
|
2225 | ||
|
2
may 23
|
2437 | ||
|
1
abr 23
|
2605 | ||
Work orders & material consumptions
Resuelto
|
|
1
ago 22
|
3557 | |
|
0
jun 22
|
1486 |