Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

I am getting an error, Please Help.. How can I create Manufacturing orders automatically (via code) for BOM components of another Manufacturing order when Saving a Manufacturing Order ?

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
Niyas
1 Répondre
3031 Vues
Avatar
Jaseel P M

I written a query for create manufacturing order in create method of mrp.production but Manufacturing Orders created through my query is not deletable, instead of that I am getting an error
 " Cannot delete a manufacturing order in done state" 
even the order is in draft state and I am getting another error,
" The quantity to produce must be positive! "
when I try to click "Mark as Done" for Manufacturing Orders created through my query.

Here is my code below,

def _create_mo_recursive(self, component, main_mo):
if component.stock_in_hand bom = self.env['mrp.bom'].search(
[('product_tmpl_id', '=', component.product_id.product_tmpl_id.id)], limit=1)
if bom:
vals = {
'product_id': component.product_id.id,
'bom_id': bom.id,
'state': 'draft',
'product_qty': component.product_uom_qty,
'qty_producing': 0,
'product_uom_id': component.product_uom.id,
'reference': main_mo.name,
'main_mo_id': main_mo.id,
}
new_mo = self.env['mrp.production'].create(vals)

for bom_line in bom.bom_line_ids:
move_raw_vals = {
'product_id': bom_line.product_id.id,
# 'production_id': new_mo.id,
'name': bom_line.product_id.name,
'product_uom_qty': bom_line.product_qty * component.product_uom_qty,
'product_uom': bom_line.product_uom_id.id,
'location_id': 8,
'location_dest_id': 15,
}
new_mo.write({'move_raw_ids': [(0, 0, move_raw_vals)]})
# new_mo_stock = self.env['stock.move'].create(move_raw_vals)

for operation in bom.operation_ids:
workorder_vals = {
'name': operation.name,
'workcenter_id': operation.workcenter_id.id,
'duration_expected': operation.time_cycle,
'product_uom_id': component.product_uom.id,
}
new_mo.write({'workorder_ids': [(0, 0, workorder_vals)]})

for sub_component in new_mo.move_raw_ids:
self._create_mo_recursive(sub_component, main_mo)
@api.model
def create(self, vals):
res = super(MrpProductionExtent, self).create(vals)
res.create_mo_for_bom_component()
return res

Please give me solution for this problem.

I hope anyone will give me the solution.

Thank You.

0
Avatar
Ignorer
Avatar
Jaseel P M
Auteur Meilleure réponse

I got the solution after wrote 1 more query for add an entry of Manufacturing product in stock.move,

here is my new code,

def _create_mo_recursive(self, component, main_mo):
if component.stock_in_hand bom = self.env['mrp.bom'].search(
[('product_tmpl_id', '=', component.product_id.product_tmpl_id.id)], limit=1)
if bom:
vals = {
'product_id': component.product_id.id,
'bom_id': bom.id,
'state': 'draft',
'product_qty': component.product_uom_qty,
# 'qty_producing': component.product_uom_qty,
'product_uom_id': component.product_uom.id,
'reference': main_mo.name,
'main_mo_id': main_mo.id,
}
new_mo = self.env['mrp.production'].create(vals)
print(bom.product_id.name)
bom_main_val = {
'production_id': new_mo.id,
'product_id': new_mo.product_id.id,
# 'description': new_mo.product_id.name,
# 'production_id': new_mo.id,
'name': new_mo.product_id.name,
'product_uom_qty': component.product_uom_qty,
'product_uom': bom.product_uom_id.id,
'location_id': 15,
'location_dest_id': 8,
}
print(bom_main_val)
new_mo_stock = self.env['stock.move'].create(bom_main_val)

for bom_line in bom.bom_line_ids:
move_raw_vals = {
'product_id': bom_line.product_id.id,
# 'production_id': new_mo.id,
'name': bom_line.product_id.name,
'product_uom_qty': bom_line.product_qty * component.product_uom_qty,
'product_uom': bom_line.product_uom_id.id,
'location_id': 8,
'location_dest_id': 15,
}
new_mo.write({'move_raw_ids': [(0, 0, move_raw_vals)]})
# new_mo_stock = self.env['stock.move'].create(move_raw_vals)

for operation in bom.operation_ids:
workorder_vals = {
'name': operation.name,
'workcenter_id': operation.workcenter_id.id,
'duration_expected': operation.time_cycle,
'product_uom_id': component.product_uom.id,
}
new_mo.write({'workorder_ids': [(0, 0, workorder_vals)]})

for sub_component in new_mo.move_raw_ids:
self._create_mo_recursive(sub_component, main_mo)
@api.model
def create(self, vals):
res = super(MrpProductionExtent, self).create(vals)
res.create_mo_for_bom_component()
return res


0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
How to Auto checkout attendance in odoo15 Résolu
Niyas
Avatar
Avatar
1
sept. 23
2882
How will i add two unit of measure
Niyas
Avatar
Avatar
2
juin 23
2998
Project and employee
Niyas
Avatar
Avatar
1
mai 20
2845
Project and employee
Niyas
Avatar
Avatar
1
mai 20
3325
How to loadXML in Odoo js 16 Résolu
Niyas Cybrosys
Avatar
Avatar
2
août 23
3744
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now