Cherry pick of 20858c2a8805d9ec08edb98b090badf6c73fc342 failed

stdout:

stderr:
13:41:03.985365 git.c:344               trace: built-in: git cherry-pick 20858c2a8805d9ec08edb98b090badf6c73fc342
error: Cherry-picking is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: cherry-pick failed
----------
status:

closes odoo/odoo#79933

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
JF Aubert
2021-11-17 15:52:19 +00:00
parent 8467ad6518
commit 047f2e556f
12 changed files with 46 additions and 21 deletions
@@ -69,11 +69,6 @@ class MrpProduction(models.Model):
return action
return {'type': 'ir.actions.act_window_close'}
def action_subcontracting_discard_remaining_components(self):
self.ensure_one()
self.qty_producing = 0
return {'type': 'ir.actions.act_window_close'}
def _pre_button_mark_done(self):
if self._get_subcontract_move():
return True
@@ -144,7 +139,7 @@ class MrpProduction(models.Model):
def filter_in(mo):
if mo.state in ('done', 'cancel'):
return False
if float_is_zero(mo.qty_producing, precision_rounding=mo.product_uom_id.rounding):
if not mo.subcontracting_has_been_recorded:
return False
if not all(line.lot_id for line in mo.move_raw_ids.filtered(lambda sm: sm.has_tracking != 'none').move_line_ids):
return False
@@ -23,11 +23,11 @@ class StockPicking(models.Model):
# Hide if not encoding state or it is not a subcontracting picking
if picking.state in ('draft', 'cancel', 'done') or not picking._is_subcontract():
continue
subconctracted_moves = picking.move_ids.filtered(lambda m: m.is_subcontract)
if subconctracted_moves._subcontrating_should_be_record():
subcontracted_moves = picking.move_ids.filtered(lambda m: m.is_subcontract)
if subcontracted_moves._subcontrating_should_be_record():
picking.display_action_record_components = 'mandatory'
continue
if subconctracted_moves._subcontrating_can_be_record():
if subcontracted_moves._subcontrating_can_be_record():
picking.display_action_record_components = 'facultative'
# -------------------------------------------------------------------------
@@ -39,11 +39,13 @@ class StockPicking(models.Model):
for move in self.move_ids.filtered(lambda move: move.is_subcontract):
# Auto set qty_producing/lot_producing_id of MO wasn't recorded
# manually (if the flexible + record_component or has tracked component)
production = move._get_subcontract_production().filtered(lambda p: not p._has_been_recorded())
if any(production._has_been_recorded() for production in move._get_subcontract_production()):
continue
production = move._get_subcontract_production()
if not production:
continue
if len(production) > 1:
raise UserError("It shouldn't happen to have multiple production to record for the same subconctracted move")
raise UserError("It shouldn't happen to have multiple production to record for the same subcontracted move")
# Manage additional quantities
quantity_done_move = move.product_uom._compute_quantity(move.quantity_done, production.product_uom_id)
if float_compare(production.product_qty, quantity_done_move, precision_rounding=production.product_uom_id.rounding) == -1:
@@ -58,6 +60,7 @@ class StockPicking(models.Model):
production.lot_producing_id = move_line.lot_id
production.qty_producing = move_line.product_uom_id._compute_quantity(move_line.qty_done, production.product_uom_id)
production._set_qty_producing()
production.subcontracting_has_been_recorded = True
if move_line != move.move_line_ids[-1]:
backorder = production._generate_backorder_productions(close_mo=False)
# The move_dest_ids won't be set because the _split filter out done move
@@ -19,7 +19,7 @@
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='lot_producing_id']" position="attributes">
<attribute name="attrs">{'invisible': [('product_tracking', 'in', ('none', False))]}</attribute>
<attribute name="attrs">{'invisible': [('product_tracking', 'in', ('none', False))], 'required': [('product_tracking', 'not in', ('none', False))]}</attribute>
</xpath>
<xpath expr="//page[@name='miscellaneous']" position="attributes">
<attribute name="invisible">1</attribute>
@@ -46,7 +46,7 @@
<footer>
<button name="subcontracting_record_component" attrs="{'invisible': ['|', ('state', '=', 'to_close'), ('qty_producing', '&lt;', 0.001)]}" string="Continue" type="object" class="oe_highlight" data-hotkey="q"/>
<button name="subcontracting_record_component" attrs="{'invisible': [('state', '!=', 'to_close')]}" string="Record Production" type="object" class="oe_highlight" data-hotkey="q"/>
<button name="action_subcontracting_discard_remaining_components" string="Discard" type="object" data-hotkey="z"/>
<button string="Discard" special="cancel" data-hotkey="z" />
</footer>
</xpath>
</field>
@@ -15,5 +15,5 @@ class MrpConsumptionWarning(models.TransientModel):
def action_cancel(self):
mo_subcontracted_move = self.mrp_production_ids._get_subcontract_move()
if mo_subcontracted_move:
return mo_subcontracted_move._action_record_components()
return mo_subcontracted_move.filtered(lambda move: move.state not in ('done', 'cancel'))._action_record_components()
return super().action_cancel()
@@ -5,3 +5,4 @@ from . import stock_picking
from . import res_company
from . import stock_warehouse
from . import purchase
from . import stock_rule
@@ -13,8 +13,8 @@ class PurchaseOrder(models.Model):
if not self.dest_address_id:
return super()._get_destination_location()
if self.mrp_production_count:
mrp_production_ids = self._get_mrp_productions()
mrp_production_ids = self._get_mrp_productions(remove_archived_picking_types=False)
if mrp_production_ids:
if self.dest_address_id in mrp_production_ids.bom_id.subcontractor_ids:
return self.dest_address_id.property_stock_subcontractor.id
elif self.sale_order_count:
@@ -11,3 +11,8 @@ class StockPicking(models.Model):
if subcontract_move.sale_line_id:
return subcontract_move.sale_line_id.order_id.warehouse_id
return super(StockPicking, self)._get_warehouse(subcontract_move)
def _action_done(self):
res = super()._action_done()
self.move_ids.move_dest_ids._action_assign()
return res
@@ -0,0 +1,13 @@
# -*- encoding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class StockRule(models.Model):
_inherit = 'stock.rule'
def _prepare_purchase_order(self, company_id, origins, values):
if 'partner_id' not in values[0] and self.location_id.id == company_id.subcontracting_location_id.id:
values[0]['partner_id'] = values[0]['group_id'].partner_id.id
return super()._prepare_purchase_order(company_id, origins, values)
@@ -8,7 +8,7 @@
'description': """
This bridge module adds some smart buttons between Purchase and Subcontracting
""",
'depends': ['mrp_subcontracting', 'purchase'],
'depends': ['mrp_subcontracting', 'purchase_mrp'],
'data': [
'views/purchase_order_views.xml',
'views/stock_picking_views.xml',
@@ -23,3 +23,9 @@ class PurchaseOrder(models.Model):
moves_subcontracted = self.order_line.move_ids.filtered(lambda m: m.is_subcontract)
subcontracted_productions = moves_subcontracted.move_orig_ids.production_id
return subcontracted_productions.picking_ids
def _get_mrp_productions(self, **kwargs):
productions = super()._get_mrp_productions(**kwargs)
if kwargs.get('remove_archived_picking_types', True):
productions = productions.filtered(lambda production: production.with_context(active_test=False).picking_type_id.active)
return productions
+5 -3
View File
@@ -18,12 +18,14 @@ class PurchaseOrder(models.Model):
@api.depends('order_line.move_dest_ids.group_id.mrp_production_ids')
def _compute_mrp_production_count(self):
for purchase in self:
purchase.mrp_production_count = len(purchase.order_line.move_dest_ids.group_id.mrp_production_ids |
purchase.order_line.move_ids.move_dest_ids.group_id.mrp_production_ids)
purchase.mrp_production_count = len(purchase._get_mrp_productions())
def _get_mrp_productions(self, **kwargs):
return self.order_line.move_dest_ids.group_id.mrp_production_ids | self.order_line.move_ids.move_dest_ids.group_id.mrp_production_ids
def action_view_mrp_productions(self):
self.ensure_one()
mrp_production_ids = (self.order_line.move_dest_ids.group_id.mrp_production_ids | self.order_line.move_ids.move_dest_ids.group_id.mrp_production_ids).ids
mrp_production_ids = self._get_mrp_productions().ids
action = {
'res_model': 'mrp.production',
'type': 'ir.actions.act_window',
@@ -59,7 +59,7 @@
<field name="default_location_dest_id_usage" invisible="1"/>
<field name="incoterm_id"/>
</xpath>
<xpath expr="//field[@name='origin']" position="after">
<xpath expr="//div[@name='reminder']" position="after">
<field name="picking_type_id" domain="[('code','=','incoming'), '|', ('warehouse_id', '=', False), ('warehouse_id.company_id', '=', company_id)]" options="{'no_create': True}" groups="stock.group_stock_multi_locations"/>
<field name="dest_address_id" groups="stock.group_stock_multi_locations" attrs="{'invisible': [('default_location_dest_id_usage', '!=', 'customer')], 'required': [('default_location_dest_id_usage', '=', 'customer')]}"/>
</xpath>