[PATCH] Upstream patch - 22092021

This commit is contained in:
Parthiv Patel committed 2021-09-22 09:36:04 +00:00
1 parent ef0be26471
commit cda845775a
5 files changed
+98 -3

No files matched your search

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<flectra>
<record model='l10n_latam.identification.type' id='l10n_latam_base.it_vat'>
<field name='l10n_pe_vat_code'>6</field>
<field name='l10n_pe_vat_code'>0</field>
</record>
<record model='l10n_latam.identification.type' id='l10n_latam_base.it_pass'>
<field name='l10n_pe_vat_code'>7</field>
+10
View File
@@ -88,3 +88,13 @@ class StockWarehouseOrderpoint(models.Model):
values = super()._prepare_procurement_values(date=date, group=group)
values['bom_id'] = self.bom_id
return values
def _post_process_scheduler(self):
""" Confirm the productions only after all the orderpoints have run their
procurement to avoid the new procurement created from the production conflict
with them. """
self.env['mrp.production'].sudo().search([
('orderpoint_id', 'in', self.ids),
('move_raw_ids', '!=', False),
]).action_confirm()
return super()._post_process_scheduler()
+1 -1
View File
@@ -57,7 +57,7 @@ class StockRule(models.Model):
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: p.move_raw_ids).action_confirm()
productions.filtered(lambda p: not p.orderpoint_id and p.move_raw_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
@@ -409,3 +409,79 @@ class TestSaleMrpFlow(TransactionCase):
# Check the components quantities that backorder_4 should have
for move in backorder_4.move_lines:
self.assertEqual(move.product_qty, 1)
def test_concurent_procurements(self):
""" Check a production created to fulfill a procurement will not
replenish more that needed if others procurements have the same products
than the production component. """
warehouse = self.env.ref('stock.warehouse0')
buy_route = warehouse.buy_pull_id.route_id
manufacture_route = warehouse.manufacture_pull_id.route_id
vendor1 = self.env['res.partner'].create({'name': 'aaa', 'email': 'from.test@example.com'})
supplier_info1 = self.env['product.supplierinfo'].create({
'name': vendor1.id,
'price': 50,
})
component = self.env['product.product'].create({
'name': 'component',
'type': 'product',
'route_ids': [(4, buy_route.id)],
'seller_ids': [(6, 0, [supplier_info1.id])],
})
finished = self.env['product.product'].create({
'name': 'finished',
'type': 'product',
'route_ids': [(4, manufacture_route.id)],
})
self.env['stock.warehouse.orderpoint'].create({
'name': 'A RR',
'location_id': warehouse.lot_stock_id.id,
'product_id': component.id,
'route_id': buy_route.id,
'product_min_qty': 0,
'product_max_qty': 0,
})
self.env['stock.warehouse.orderpoint'].create({
'name': 'A RR',
'location_id': warehouse.lot_stock_id.id,
'product_id': finished.id,
'route_id': manufacture_route.id,
'product_min_qty': 0,
'product_max_qty': 0,
})
self.env['mrp.bom'].create({
'product_id': finished.id,
'product_tmpl_id': finished.product_tmpl_id.id,
'product_uom_id': self.uom_unit.id,
'product_qty': 1.0,
'consumption': 'flexible',
'operation_ids': [
],
'type': 'normal',
'bom_line_ids': [
(0, 0, {'product_id': component.id, 'product_qty': 1}),
]})
# Delivery to trigger replenishment
picking_form = Form(self.env['stock.picking'])
picking_form.picking_type_id = warehouse.out_type_id
with picking_form.move_ids_without_package.new() as move:
move.product_id = finished
move.product_uom_qty = 3
with picking_form.move_ids_without_package.new() as move:
move.product_id = component
move.product_uom_qty = 2
picking = picking_form.save()
picking.action_confirm()
# Find PO
purchase = self.env['purchase.order.line'].search([
('product_id', '=', component.id),
]).order_id
self.assertTrue(purchase)
self.assertEqual(purchase.order_line.product_qty, 5)
@@ -915,7 +915,12 @@ registry.FullScreenHeight = publicWidget.Widget.extend({
* @override
*/
start() {
if (this.$el.outerHeight() > this._computeIdealHeight()) {
this.inModal = !!this.el.closest('.modal');
// TODO maybe review the way the public widgets work for non-visible-at-
// load snippets -> probably better to not do anything for them and
// start the widgets only once they become visible..?
if (this.$el.is(':not(:visible)') || this.$el.outerHeight() > this._computeIdealHeight()) {
// Only initialize if taller than the ideal height as some extra css
// rules may alter the full-screen-height class behavior in some
// cases (blog...).
@@ -949,6 +954,10 @@ registry.FullScreenHeight = publicWidget.Widget.extend({
*/
_computeIdealHeight() {
const windowHeight = $(window).outerHeight();
if (this.inModal) {
return (windowHeight - $('#wrapwrap').position().top);
}
// Doing it that way allows to considerer fixed headers, hidden headers,
// connected users, ...
const firstContentEl = $('#wrapwrap > main > :first-child')[0]; // first child to consider the padding-top of main