解决单一制造出库单bug
This commit is contained in:
@@ -10,8 +10,9 @@
|
|||||||
""",
|
""",
|
||||||
'category': 'YZ',
|
'category': 'YZ',
|
||||||
'website': 'https://www.sf.cs.jikimo.com',
|
'website': 'https://www.sf.cs.jikimo.com',
|
||||||
'depends': [],
|
'depends': ['account', 'sf_base', 'base', 'sale'],
|
||||||
'data': [
|
'data': [
|
||||||
|
'views/sale_process_order_view.xml'
|
||||||
],
|
],
|
||||||
'demo': [
|
'demo': [
|
||||||
],
|
],
|
||||||
|
|||||||
1
sf_bf_connect/controllers/__init__.py
Normal file
1
sf_bf_connect/controllers/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .import controllers
|
||||||
32
sf_bf_connect/controllers/controllers.py
Normal file
32
sf_bf_connect/controllers/controllers.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
from datetime import date, timedelta
|
||||||
|
from odoo import http
|
||||||
|
from odoo.http import request
|
||||||
|
from odoo.addons.mrs_gateway_api.models.common import Common
|
||||||
|
from odoo.addons.mrs_gateway_api.models.basicdata_str import BasicDataStr
|
||||||
|
|
||||||
|
|
||||||
|
class Sf_Bf_Connect(http.Controller):
|
||||||
|
|
||||||
|
@http.route('/api/bfm_process_order/list', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
|
cors="*")
|
||||||
|
def get_bfm_process_order_list(self, **kw):
|
||||||
|
"""
|
||||||
|
获取业务平台传送来的业务平台订单
|
||||||
|
:param kw:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
result = json.loads('bfm_process_order_list')
|
||||||
|
for item in result:
|
||||||
|
self.env['mrs.production.process'].create({
|
||||||
|
"id": item['id'],
|
||||||
|
"model_file": item['model_file'],
|
||||||
|
"model_name": item['model_name'],
|
||||||
|
"type": item['type'],
|
||||||
|
"surface_technics": item['surface_technics'],
|
||||||
|
"unit_price": item['unit_price'],
|
||||||
|
"amount": item['amount'],
|
||||||
|
"money": item['money']
|
||||||
|
})
|
||||||
2
sf_bf_connect/models/__init__.py
Normal file
2
sf_bf_connect/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
from . import sf_process_order
|
||||||
|
|
||||||
34
sf_bf_connect/models/sf_process_order.py
Normal file
34
sf_bf_connect/models/sf_process_order.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
from odoo import models,fields
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
class bfmOrderLine(models.Model):
|
||||||
|
_name = 'sf.bfm.order.line'
|
||||||
|
_description = '业务平台订单'
|
||||||
|
|
||||||
|
model_file = fields.Binary('模型文件', attachment=False)
|
||||||
|
model_name = fields.char('模型名称')
|
||||||
|
type = fields.Many2one('mrs.materials.model', '型号')
|
||||||
|
surface_technics = fields.Many2one('mrs.production.process', string='表面工艺')
|
||||||
|
# technological_parameter = fields.Many2one('',string='工艺参数')
|
||||||
|
unit_price = fields.Float('单价')
|
||||||
|
amount = fields.Integer('数量')
|
||||||
|
money = fields.Float('金额')
|
||||||
|
|
||||||
|
|
||||||
|
class sale(models.Model):
|
||||||
|
_inherit = 'sale.order'
|
||||||
|
|
||||||
|
bfm_process_order_ids = fields.Many2one('sf.bfm.order.line', string='业务平台订单')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
18
sf_bf_connect/views/sale_process_order_view.xml
Normal file
18
sf_bf_connect/views/sale_process_order_view.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record model="ir.ui.view" id="view_sf_form_inherit">
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//page[@name='Customer Signature']" position="before">
|
||||||
|
<page string="Bfm Line">
|
||||||
|
<group>
|
||||||
|
<field name="bfm_process_order_ids"/>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@@ -29,163 +29,232 @@ class MrpProduction(models.Model):
|
|||||||
_inherit = 'mrp.production'
|
_inherit = 'mrp.production'
|
||||||
_description = "制造订单"
|
_description = "制造订单"
|
||||||
|
|
||||||
# @api.model
|
|
||||||
# def create(self, values):
|
|
||||||
# n = values
|
|
||||||
# if values['product_qty']== 1.0:
|
|
||||||
# return self.env['mrp.production'].create1(values)
|
|
||||||
# else:
|
|
||||||
# for i in range(int(values.get('product_qty'))):
|
|
||||||
# b = n
|
|
||||||
# b['product_qty'] = 1.0
|
|
||||||
# self.env['mrp.production'].create1(b)
|
|
||||||
|
|
||||||
# @api.model
|
|
||||||
# def create(self, values):
|
|
||||||
# # Remove from `move_finished_ids` the by-product moves and then move `move_byproduct_ids`
|
|
||||||
# # into `move_finished_ids` to avoid duplicate and inconsistency.
|
|
||||||
# if values.get('move_finished_ids', False):
|
|
||||||
# values['move_finished_ids'] = list(
|
|
||||||
# filter(lambda move: move[2]['byproduct_id'] is False, values['move_finished_ids']))
|
|
||||||
# if values.get('move_byproduct_ids', False):
|
|
||||||
# values['move_finished_ids'] = values.get('move_finished_ids', []) + values['move_byproduct_ids']
|
|
||||||
# del values['move_byproduct_ids']
|
|
||||||
# if not values.get('name', False) or values['name'] == _('New'):
|
|
||||||
# picking_type_id = values.get('picking_type_id') or self._get_default_picking_type()
|
|
||||||
# picking_type_id = self.env['stock.picking.type'].browse(picking_type_id)
|
|
||||||
# if picking_type_id:
|
|
||||||
# values['name'] = picking_type_id.sequence_id.next_by_id()
|
|
||||||
# else:
|
|
||||||
# values['name'] = self.env['ir.sequence'].next_by_code('mrp.production') or _('New')
|
|
||||||
# if not values.get('procurement_group_id'):
|
|
||||||
# procurement_group_vals = self._prepare_procurement_group_vals(values)
|
|
||||||
# values['procurement_group_id'] = self.env["procurement.group"].create(procurement_group_vals).id
|
|
||||||
# production = super(MrpProduction, self).create(values)
|
|
||||||
# (production.move_raw_ids | production.move_finished_ids).write({
|
|
||||||
# 'group_id': production.procurement_group_id.id,
|
|
||||||
# 'origin': production.name
|
|
||||||
# })
|
|
||||||
# production.move_raw_ids.write({'date': production.date_planned_start})
|
|
||||||
# production.move_finished_ids.write({'date': production.date_planned_finished})
|
|
||||||
# # Trigger move_raw creation when importing a file
|
|
||||||
# if 'import_file' in self.env.context:
|
|
||||||
# production._onchange_move_raw()
|
|
||||||
# production._onchange_move_finished()
|
|
||||||
# return production
|
|
||||||
|
|
||||||
|
|
||||||
class StockRule(models.Model):
|
class StockRule(models.Model):
|
||||||
_inherit = 'stock.rule'
|
_inherit = 'stock.rule'
|
||||||
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _run_manufacture(self, procurements):
|
def _run_pull(self, procurements):
|
||||||
productions_values_by_company = defaultdict(list)
|
moves_values_by_company = defaultdict(list)
|
||||||
errors = []
|
mtso_products_by_locations = defaultdict(list)
|
||||||
|
|
||||||
|
# To handle the `mts_else_mto` procure method, we do a preliminary loop to
|
||||||
|
# isolate the products we would need to read the forecasted quantity,
|
||||||
|
# in order to to batch the read. We also make a sanitary check on the
|
||||||
|
# `location_src_id` field.
|
||||||
|
|
||||||
|
# list1 = []
|
||||||
|
# for item in procurements:
|
||||||
|
# num = int(item[0].product_qty)
|
||||||
|
# if num > 1:
|
||||||
|
# for no in range(1, num+1):
|
||||||
|
#
|
||||||
|
# Procurement = namedtuple('Procurement', ['product_id', 'product_qty',
|
||||||
|
# 'product_uom', 'location_id', 'name', 'origin',
|
||||||
|
# 'company_id',
|
||||||
|
# 'values'])
|
||||||
|
# s = Procurement(product_id=item[0].product_id,product_qty=1.0,product_uom=item[0].product_uom,
|
||||||
|
# location_id=item[0].location_id,
|
||||||
|
# name=item[0].name,
|
||||||
|
# origin=item[0].origin,
|
||||||
|
# company_id=item[0].company_id,
|
||||||
|
# values=item[0].values,
|
||||||
|
# )
|
||||||
|
# item1 = list(item)
|
||||||
|
# item1[0]=s
|
||||||
|
#
|
||||||
|
# list1.append(tuple(item1))
|
||||||
|
# else:
|
||||||
|
# list1.append(item)
|
||||||
|
|
||||||
for procurement, rule in procurements:
|
for procurement, rule in procurements:
|
||||||
if float_compare(procurement.product_qty, 0, precision_rounding=procurement.product_uom.rounding) <= 0:
|
if not rule.location_src_id:
|
||||||
# If procurement contains negative quantity, don't create a MO that would be for a negative value.
|
msg = _('No source location defined on stock rule: %s!') % (rule.name,)
|
||||||
continue
|
raise ProcurementException([(procurement, msg)])
|
||||||
bom = rule._get_matching_bom(procurement.product_id, procurement.company_id, procurement.values)
|
|
||||||
|
|
||||||
|
if rule.procure_method == 'mts_else_mto':
|
||||||
|
mtso_products_by_locations[rule.location_src_id].append(procurement.product_id.id)
|
||||||
|
|
||||||
|
# Get the forecasted quantity for the `mts_else_mto` procurement.
|
||||||
|
forecasted_qties_by_loc = {}
|
||||||
|
for location, product_ids in mtso_products_by_locations.items():
|
||||||
|
products = self.env['product.product'].browse(product_ids).with_context(location=location.id)
|
||||||
|
forecasted_qties_by_loc[location] = {product.id: product.free_qty for product in products}
|
||||||
|
|
||||||
|
# Prepare the move values, adapt the `procure_method` if needed.
|
||||||
|
procurements = sorted(procurements, key=lambda proc: float_compare(proc[0].product_qty, 0.0,
|
||||||
|
precision_rounding=proc[
|
||||||
|
0].product_uom.rounding) > 0)
|
||||||
|
list2 = []
|
||||||
|
for item in procurements:
|
||||||
|
num = int(item[0].product_qty)
|
||||||
product = self.env['product.template'].search(
|
product = self.env['product.template'].search(
|
||||||
["&", ("name", '=', procurement.product_id.display_name), ('single_manufacturing', '!=', False)])
|
["&", ("name", '=', item[0].product_id.display_name), ('single_manufacturing', '!=', False)])
|
||||||
if not product:
|
if product:
|
||||||
productions_values_by_company[procurement.company_id.id].append(
|
if num > 1:
|
||||||
rule._prepare_mo_vals1(*procurement, bom))
|
for no in range(1, num + 1):
|
||||||
else:
|
Procurement = namedtuple('Procurement', ['product_id', 'product_qty',
|
||||||
orders_vals = rule._prepare_mo_vals(*procurement, bom)
|
'product_uom', 'location_id', 'name', 'origin',
|
||||||
|
'company_id',
|
||||||
|
'values'])
|
||||||
|
s = Procurement(product_id=item[0].product_id, product_qty=1.0, product_uom=item[0].product_uom,
|
||||||
|
location_id=item[0].location_id,
|
||||||
|
name=item[0].name,
|
||||||
|
origin=item[0].origin,
|
||||||
|
company_id=item[0].company_id,
|
||||||
|
values=item[0].values,
|
||||||
|
)
|
||||||
|
item1 = list(item)
|
||||||
|
item1[0] = s
|
||||||
|
|
||||||
if isinstance(orders_vals, list):
|
list2.append(tuple(item1))
|
||||||
for vals in orders_vals:
|
|
||||||
productions_values_by_company[procurement.company_id.id].append(vals)
|
|
||||||
else:
|
else:
|
||||||
productions_values_by_company[procurement.company_id.id].append(orders_vals)
|
list2.append(item)
|
||||||
|
else:
|
||||||
|
list2.append(item)
|
||||||
|
|
||||||
if errors:
|
for procurement, rule in list2:
|
||||||
raise ProcurementException(errors)
|
procure_method = rule.procure_method
|
||||||
|
if rule.procure_method == 'mts_else_mto':
|
||||||
|
qty_needed = procurement.product_uom._compute_quantity(procurement.product_qty,
|
||||||
|
procurement.product_id.uom_id)
|
||||||
|
if float_compare(qty_needed, 0, precision_rounding=procurement.product_id.uom_id.rounding) <= 0:
|
||||||
|
procure_method = 'make_to_order'
|
||||||
|
for move in procurement.values.get('group_id', self.env['procurement.group']).stock_move_ids:
|
||||||
|
if move.rule_id == rule and float_compare(move.product_uom_qty, 0,
|
||||||
|
precision_rounding=move.product_uom.rounding) > 0:
|
||||||
|
procure_method = move.procure_method
|
||||||
|
break
|
||||||
|
forecasted_qties_by_loc[rule.location_src_id][procurement.product_id.id] -= qty_needed
|
||||||
|
elif float_compare(qty_needed, forecasted_qties_by_loc[rule.location_src_id][procurement.product_id.id],
|
||||||
|
precision_rounding=procurement.product_id.uom_id.rounding) > 0:
|
||||||
|
procure_method = 'make_to_order'
|
||||||
|
else:
|
||||||
|
forecasted_qties_by_loc[rule.location_src_id][procurement.product_id.id] -= qty_needed
|
||||||
|
procure_method = 'make_to_stock'
|
||||||
|
|
||||||
for company_id, productions_values in productions_values_by_company.items():
|
move_values = rule._get_stock_move_values(*procurement)
|
||||||
# create the MO as SUPERUSER because the current user may not have the rights to do it (mto product launched by a sale for example)
|
move_values['procure_method'] = procure_method
|
||||||
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
|
moves_values_by_company[procurement.company_id.id].append(move_values)
|
||||||
productions_values)
|
|
||||||
self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
|
||||||
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
|
||||||
productions._create_workorder()
|
|
||||||
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
|
||||||
(
|
|
||||||
p.move_dest_ids.procure_method != 'make_to_order' and not p.move_raw_ids and not p.workorder_ids)).action_confirm()
|
|
||||||
|
|
||||||
for production in productions:
|
for company_id, moves_values in moves_values_by_company.items():
|
||||||
origin_production = production.move_dest_ids and production.move_dest_ids[
|
# create the move as SUPERUSER because the current user may not have the rights to do it (mto product launched by a sale for example)
|
||||||
0].raw_material_production_id or False
|
moves = self.env['stock.move'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(moves_values)
|
||||||
orderpoint = production.orderpoint_id
|
# Since action_confirm launch following procurement_group we should activate it.
|
||||||
if orderpoint and orderpoint.create_uid.id == SUPERUSER_ID and orderpoint.trigger == 'manual':
|
moves._action_confirm()
|
||||||
production.message_post(
|
|
||||||
body=_('This production order has been created from Replenishment Report.'),
|
|
||||||
message_type='comment',
|
|
||||||
subtype_xmlid='mail.mt_note')
|
|
||||||
elif orderpoint:
|
|
||||||
production.message_post_with_view(
|
|
||||||
'mail.message_origin_link',
|
|
||||||
values={'self': production, 'origin': orderpoint},
|
|
||||||
subtype_id=self.env.ref('mail.mt_note').id)
|
|
||||||
elif origin_production:
|
|
||||||
production.message_post_with_view(
|
|
||||||
'mail.message_origin_link',
|
|
||||||
values={'self': production, 'origin': origin_production},
|
|
||||||
subtype_id=self.env.ref('mail.mt_note').id)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _prepare_mo_vals1(self, product_id, product_qty, product_uom, location_id, name, origin, company_id, values,
|
# @api.model
|
||||||
bom):
|
# def _run_manufacture(self, procurements):
|
||||||
date_planned = self._get_date_planned(product_id, company_id, values)
|
# productions_values_by_company = defaultdict(list)
|
||||||
date_deadline = values.get('date_deadline') or date_planned + relativedelta(
|
# errors = []
|
||||||
days=company_id.manufacturing_lead) + relativedelta(days=product_id.produce_delay)
|
# for procurement, rule in procurements:
|
||||||
mo_values = {
|
# if float_compare(procurement.product_qty, 0, precision_rounding=procurement.product_uom.rounding) <= 0:
|
||||||
'origin': origin,
|
# # If procurement contains negative quantity, don't create a MO that would be for a negative value.
|
||||||
'product_id': product_id.id,
|
# continue
|
||||||
'product_description_variants': values.get('product_description_variants'),
|
# bom = rule._get_matching_bom(procurement.product_id, procurement.company_id, procurement.values)
|
||||||
'product_qty': product_qty,
|
#
|
||||||
'product_uom_id': product_uom.id,
|
# product = self.env['product.template'].search(
|
||||||
'location_src_id': self.location_src_id.id or self.picking_type_id.default_location_src_id.id or location_id.id,
|
# ["&", ("id", '=', procurement.product_id.id), ('single_manufacturing', '!=', False)])
|
||||||
'location_dest_id': location_id.id,
|
# if not product:
|
||||||
'bom_id': bom.id,
|
# productions_values_by_company[procurement.company_id.id].append(
|
||||||
'date_deadline': date_deadline,
|
# rule._prepare_mo_vals1(*procurement, bom))
|
||||||
'date_planned_start': date_planned,
|
# else:
|
||||||
'date_planned_finished': fields.Datetime.from_string(values['date_planned']),
|
# orders_vals = rule._prepare_mo_vals(*procurement, bom)
|
||||||
'procurement_group_id': False,
|
#
|
||||||
'propagate_cancel': self.propagate_cancel,
|
# if isinstance(orders_vals, list):
|
||||||
'orderpoint_id': values.get('orderpoint_id', False) and values.get('orderpoint_id').id,
|
# for vals in orders_vals:
|
||||||
'picking_type_id': self.picking_type_id.id or values['warehouse_id'].manu_type_id.id,
|
# productions_values_by_company[procurement.company_id.id].append(vals)
|
||||||
'company_id': company_id.id,
|
# else:
|
||||||
'move_dest_ids': values.get('move_dest_ids') and [(4, x.id) for x in values['move_dest_ids']] or False,
|
# productions_values_by_company[procurement.company_id.id].append(orders_vals)
|
||||||
'user_id': False,
|
#
|
||||||
}
|
# if errors:
|
||||||
# Use the procurement group created in _run_pull mrp override
|
# raise ProcurementException(errors)
|
||||||
# Preserve the origin from the original stock move, if available
|
#
|
||||||
if location_id.warehouse_id.manufacture_steps == 'pbm_sam' and values.get('move_dest_ids') and values.get(
|
# for company_id, productions_values in productions_values_by_company.items():
|
||||||
'group_id') and values['move_dest_ids'][0].origin != values['group_id'].name:
|
# # create the MO as SUPERUSER because the current user may not have the rights to do it (mto product launched by a sale for example)
|
||||||
origin = values['move_dest_ids'][0].origin
|
# productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
|
||||||
mo_values.update({
|
# productions_values)
|
||||||
'name': values['group_id'].name,
|
# a = self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||||
'procurement_group_id': values['group_id'].id,
|
# b = self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||||
'origin': origin,
|
# c = productions._create_workorder()
|
||||||
})
|
# productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
||||||
return mo_values
|
# (
|
||||||
|
# p.move_dest_ids.procure_method != 'make_to_order' and not p.move_raw_ids and not p.workorder_ids)).action_confirm()
|
||||||
|
#
|
||||||
|
# for production in productions:
|
||||||
|
# origin_production = production.move_dest_ids and production.move_dest_ids[
|
||||||
|
# 0].raw_material_production_id or False
|
||||||
|
# orderpoint = production.orderpoint_id
|
||||||
|
# if orderpoint and orderpoint.create_uid.id == SUPERUSER_ID and orderpoint.trigger == 'manual':
|
||||||
|
# production.message_post(
|
||||||
|
# body=_('This production order has been created from Replenishment Report.'),
|
||||||
|
# message_type='comment',
|
||||||
|
# subtype_xmlid='mail.mt_note')
|
||||||
|
# elif orderpoint:
|
||||||
|
# production.message_post_with_view(
|
||||||
|
# 'mail.message_origin_link',
|
||||||
|
# values={'self': production, 'origin': orderpoint},
|
||||||
|
# subtype_id=self.env.ref('mail.mt_note').id)
|
||||||
|
# elif origin_production:
|
||||||
|
# production.message_post_with_view(
|
||||||
|
# 'mail.message_origin_link',
|
||||||
|
# values={'self': production, 'origin': origin_production},
|
||||||
|
# subtype_id=self.env.ref('mail.mt_note').id)
|
||||||
|
# return True
|
||||||
|
#
|
||||||
|
# def _prepare_mo_vals1(self, product_id, product_qty, product_uom, location_id, name, origin, company_id, values,
|
||||||
|
# bom):
|
||||||
|
# date_planned = self._get_date_planned(product_id, company_id, values)
|
||||||
|
# date_deadline = values.get('date_deadline') or date_planned + relativedelta(
|
||||||
|
# days=company_id.manufacturing_lead) + relativedelta(days=product_id.produce_delay)
|
||||||
|
# mo_values = {
|
||||||
|
# 'origin': origin,
|
||||||
|
# 'product_id': product_id.id,
|
||||||
|
# 'product_description_variants': values.get('product_description_variants'),
|
||||||
|
# 'product_qty': product_qty,
|
||||||
|
# 'product_uom_id': product_uom.id,
|
||||||
|
# 'location_src_id': self.location_src_id.id or self.picking_type_id.default_location_src_id.id or location_id.id,
|
||||||
|
# 'location_dest_id': location_id.id,
|
||||||
|
# 'bom_id': bom.id,
|
||||||
|
# 'date_deadline': date_deadline,
|
||||||
|
# 'date_planned_start': date_planned,
|
||||||
|
# 'date_planned_finished': fields.Datetime.from_string(values['date_planned']),
|
||||||
|
# 'procurement_group_id': False,
|
||||||
|
# 'propagate_cancel': self.propagate_cancel,
|
||||||
|
# 'orderpoint_id': values.get('orderpoint_id', False) and values.get('orderpoint_id').id,
|
||||||
|
# 'picking_type_id': self.picking_type_id.id or values['warehouse_id'].manu_type_id.id,
|
||||||
|
# 'company_id': company_id.id,
|
||||||
|
# 'move_dest_ids': values.get('move_dest_ids') and [(4, x.id) for x in values['move_dest_ids']] or False,
|
||||||
|
# 'user_id': False,
|
||||||
|
# }
|
||||||
|
# # Use the procurement group created in _run_pull mrp override
|
||||||
|
# # Preserve the origin from the original stock move, if available
|
||||||
|
# if location_id.warehouse_id.manufacture_steps == 'pbm_sam' and values.get('move_dest_ids') and values.get(
|
||||||
|
# 'group_id') and values['move_dest_ids'][0].origin != values['group_id'].name:
|
||||||
|
# origin = values['move_dest_ids'][0].origin
|
||||||
|
# mo_values.update({
|
||||||
|
# 'name': values['group_id'].name,
|
||||||
|
# 'procurement_group_id': values['group_id'].id,
|
||||||
|
# 'origin': origin,
|
||||||
|
# })
|
||||||
|
# return mo_values
|
||||||
|
#
|
||||||
|
# def _prepare_mo_vals(self, product_id, product_qty, product_uom, location_id, name, origin, company_id, values,
|
||||||
|
# bom):
|
||||||
|
#
|
||||||
|
# mo_lists = []
|
||||||
|
# for num in range(1, int(product_qty) + 1):
|
||||||
|
# vals = super(StockRule, self)._prepare_mo_vals(product_id, 1.0, product_uom, location_id, name, origin,
|
||||||
|
# company_id, values,
|
||||||
|
# bom)
|
||||||
|
# vals.update({
|
||||||
|
# # 'name': values['group_id'].name,
|
||||||
|
# 'procurement_group_id': values['group_id'].id,
|
||||||
|
# # 'origin': origin,
|
||||||
|
# })
|
||||||
|
# mo_lists.append(vals)
|
||||||
|
#
|
||||||
|
# return mo_lists
|
||||||
|
|
||||||
def _prepare_mo_vals(self, product_id, product_qty, product_uom, location_id, name, origin, company_id, values,
|
|
||||||
bom):
|
|
||||||
|
|
||||||
mo_lists = []
|
|
||||||
for num in range(1, int(product_qty) + 1):
|
|
||||||
vals = super(StockRule, self)._prepare_mo_vals(product_id, 1.0, product_uom, location_id, name, origin,
|
|
||||||
company_id, values,
|
|
||||||
bom)
|
|
||||||
vals.update({
|
|
||||||
# 'name': values['group_id'].name,
|
|
||||||
'procurement_group_id': values['group_id'].id,
|
|
||||||
# 'origin': origin,
|
|
||||||
})
|
|
||||||
mo_lists.append(vals)
|
|
||||||
|
|
||||||
return mo_lists
|
|
||||||
|
|||||||
Reference in New Issue
Block a user