mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
user store field sale info not fulfill correctly MO always empty.
Save sale info from create MO from procurement
This commit is contained in:
@@ -4,3 +4,4 @@
|
||||
|
||||
from . import mrp_production
|
||||
from . import mrp_workorder
|
||||
from . import procurement
|
||||
|
||||
@@ -10,32 +10,10 @@ class MrpProduction(models.Model):
|
||||
|
||||
sale_id = fields.Many2one(
|
||||
'sale.order',
|
||||
compute='_compute_sale_info',
|
||||
string='Sale order',
|
||||
readonly=True,
|
||||
store=True)
|
||||
readonly=True)
|
||||
partner_id = fields.Many2one(
|
||||
'res.partner',
|
||||
compute='_compute_sale_info',
|
||||
string='Customer',
|
||||
store=True)
|
||||
commitment_date = fields.Datetime(compute='_compute_sale_info',
|
||||
string='Commitment Date')
|
||||
|
||||
@api.multi
|
||||
def _compute_sale_info(self):
|
||||
def get_parent_move(move):
|
||||
if move.move_dest_id:
|
||||
return get_parent_move(move.move_dest_id)
|
||||
return move
|
||||
|
||||
for production in self:
|
||||
move = get_parent_move(production.move_finished_ids)
|
||||
proc = move.procurement_id
|
||||
production.sale_id = proc and proc.sale_line_id and \
|
||||
proc.sale_line_id.order_id.id or False
|
||||
production.partner_id = production.sale_id and \
|
||||
production.sale_id.partner_id and \
|
||||
production.sale_id.partner_id.id or False
|
||||
production.commitment_date = production.sale_id and \
|
||||
production.sale_id.commitment_date or ''
|
||||
readonly=True,
|
||||
string='Customer')
|
||||
commitment_date = fields.Datetime(string='Commitment Date')
|
||||
|
||||
31
mrp_sale_info/models/procurement.py
Normal file
31
mrp_sale_info/models/procurement.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
class ProcurementOrder(models.Model):
|
||||
_inherit = 'procurement.order'
|
||||
|
||||
@api.multi
|
||||
def make_mo(self):
|
||||
def get_parent_move(move):
|
||||
if move.move_dest_id:
|
||||
return get_parent_move(move.move_dest_id)
|
||||
return move
|
||||
|
||||
res = super(ProcurementOrder, self).make_mo()
|
||||
for prod_id in res:
|
||||
production = self.env['mrp.production'].browse([res[prod_id]])
|
||||
move = get_parent_move(production.move_finished_ids)
|
||||
proc = move.procurement_id
|
||||
|
||||
production.sale_id = \
|
||||
proc and proc.sale_line_id and \
|
||||
proc.sale_line_id.order_id.id or False
|
||||
production.partner_id = \
|
||||
production.sale_id and production.sale_id.partner_id and \
|
||||
production.sale_id.partner_id.id or False
|
||||
production.commitment_date = \
|
||||
production.sale_id and production.sale_id.commitment_date or ''
|
||||
return res
|
||||
Reference in New Issue
Block a user