[PATCH] Upstream patch - 17032023

This commit is contained in:
Parthiv Patel
2023-03-17 08:35:53 +00:00
parent 9a3b87bb62
commit 916d660ccb
12 changed files with 115 additions and 9 deletions
+4
View File
@@ -10,6 +10,10 @@ class EventController(Controller):
@route(['''/event/<model("event.event"):event>/ics'''], type='http', auth="public")
def event_ics_file(self, event, **kwargs):
if request.env.user._is_public():
frontend_lang = request.httprequest.cookies.get('frontend_lang')
if frontend_lang:
event = event.with_context(lang=frontend_lang)
files = event._get_ics_file()
if not event.id in files:
return NotFound()
@@ -3,7 +3,7 @@
<template id="mail_client_extension.app_auth" name="Accept app">
<t t-call="web.login_layout">
<t t-set="disable_database_manager" t-value="1"/>
<form class="oe_login_form" role="form" method="post" action="/mail_client_extension/auth/confirm">
<form role="form" method="post" action="/mail_client_extension/auth/confirm">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
<input type="hidden" name="redirect" t-att-value="redirect"/>
<input type="hidden" name="scope" t-att-value="scope"/>
+8 -1
View File
@@ -959,6 +959,11 @@ class MrpProduction(models.Model):
def _get_move_raw_values(self, product_id, product_uom_qty, product_uom, operation_id=False, bom_line=False):
source_location = self.location_src_id
origin = self.name
if self.orderpoint_id:
origin = self.origin.replace(
'%s - ' % (self.orderpoint_id.display_name), '')
origin = '%s,%s' % (origin, self.name)
data = {
'sequence': bom_line.sequence if bom_line else 10,
'name': self.name,
@@ -976,7 +981,7 @@ class MrpProduction(models.Model):
'operation_id': operation_id,
'price_unit': product_id.standard_price,
'procure_method': 'make_to_stock',
'origin': self.name,
'origin': origin,
'state': 'draft',
'warehouse_id': source_location.get_warehouse().id,
'group_id': self.procurement_group_id.id,
@@ -1167,6 +1172,8 @@ class MrpProduction(models.Model):
# run scheduler for moves forecasted to not have enough in stock
self.move_raw_ids._trigger_scheduler()
self.picking_ids.filtered(
lambda p: p.state not in ['cancel', 'done']).action_confirm()
return True
def action_assign(self):
+6
View File
@@ -306,6 +306,12 @@ class StockMove(models.Model):
defaults['workorder_id'] = False
return defaults
def _prepare_procurement_origin(self):
self.ensure_one()
if self.raw_material_production_id and self.raw_material_production_id.orderpoint_id:
return self.origin
return super()._prepare_procurement_origin()
def _prepare_phantom_move_values(self, bom_line, product_qty, quantity_done):
return {
'picking_id': self.picking_id.id if self.picking_id else False,
@@ -389,6 +389,7 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon):
self.assertFalse(sam_move.move_dest_ids)
subproduction = self.env['mrp.production'].browse(production.id+1)
subproduction.invalidate_cache(fnames=['picking_ids'], ids=subproduction.ids)
sfp_pickings = subproduction.picking_ids.sorted('id')
# SFP Production: 2 pickings, 1 group
@@ -544,3 +545,56 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon):
mo.action_confirm()
self.assertEqual(self.bom.bom_line_ids.product_id + self.product_2, mo.picking_ids.move_lines.product_id)
def test_manufacturing_3_steps_trigger_reordering_rules(self):
with Form(self.warehouse) as warehouse:
warehouse.manufacture_steps = 'pbm_sam'
with Form(self.raw_product) as p:
p.route_ids.clear()
p.route_ids.add(self.warehouse.manufacture_pull_id.route_id)
# Create an additional BoM for component
product_form = Form(self.env['product.product'])
product_form.name = 'Wood'
product_form.type = 'product'
product_form.uom_id = self.uom_unit
product_form.uom_po_id = self.uom_unit
self.wood_product = product_form.save()
# Create bom for manufactured product
bom_product_form = Form(self.env['mrp.bom'])
bom_product_form.product_id = self.raw_product
bom_product_form.product_tmpl_id = self.raw_product.product_tmpl_id
bom_product_form.product_qty = 1.0
bom_product_form.type = 'normal'
with bom_product_form.bom_line_ids.new() as bom_line:
bom_line.product_id = self.wood_product
bom_line.product_qty = 1.0
bom_product_form.save()
self.env['stock.quant']._update_available_quantity(
self.finished_product, self.warehouse.lot_stock_id, -1.0)
rr_form = Form(self.env['stock.warehouse.orderpoint'])
rr_form.product_id = self.wood_product
rr_form.location_id = self.warehouse.lot_stock_id
rr_form.save()
rr_form = Form(self.env['stock.warehouse.orderpoint'])
rr_form.product_id = self.finished_product
rr_form.location_id = self.warehouse.lot_stock_id
rr_finish = rr_form.save()
rr_form = Form(self.env['stock.warehouse.orderpoint'])
rr_form.product_id = self.raw_product
rr_form.location_id = self.warehouse.lot_stock_id
rr_form.save()
self.env['procurement.group'].run_scheduler()
pickings_component = self.env['stock.picking'].search(
[('product_id', '=', self.wood_product.id)])
self.assertTrue(pickings_component)
self.assertTrue(rr_finish.name in pickings_component.origin)
+1 -1
View File
@@ -412,7 +412,7 @@ class PricelistItem(models.Model):
pricelist_id = fields.Many2one('product.pricelist', 'Pricelist', index=True, ondelete='cascade', required=True, default=_default_pricelist_id)
price_surcharge = fields.Float(
'Price Surcharge', digits='Product Price',
help='Specify the fixed amount to add or substract(if negative) to the amount calculated with the discount.')
help='Specify the fixed amount to add or subtract(if negative) to the amount calculated with the discount.')
price_discount = fields.Float('Price Discount', default=0, digits=(16, 2))
price_round = fields.Float(
'Price Rounding', digits='Product Price',
+1
View File
@@ -208,6 +208,7 @@ class Product(models.Model):
return self.description_pickingout or self.name
if picking_code == 'internal':
return self.description_picking or description
return description
def _get_domain_locations(self):
'''
+11 -2
View File
@@ -1154,7 +1154,7 @@ class StockMove(models.Model):
procurement_requests = []
for move in move_create_proc:
values = move._prepare_procurement_values()
origin = (move.group_id and move.group_id.name or (move.origin or move.picking_id.name or "/"))
origin = move._prepare_procurement_origin()
procurement_requests.append(self.env['procurement.group'].Procurement(
move.product_id, move.product_uom_qty, move.product_uom,
move.location_id, move.rule_id and move.rule_id.name or "/",
@@ -1177,6 +1177,10 @@ class StockMove(models.Model):
moves.filtered(lambda move: not move.picking_id.immediate_transfer and move._should_bypass_reservation() and move.state == 'confirmed')._action_assign()
return moves
def _prepare_procurement_origin(self):
self.ensure_one()
return self.group_id and self.group_id.name or (self.origin or self.picking_id.name or "/")
def _prepare_procurement_values(self):
""" Prepare specific key for moves or other componenets that will be created from a stock rule
comming from a stock move. This method could be override in order to add other custom key that could
@@ -1805,6 +1809,7 @@ class StockMove(models.Model):
return
orderpoints_by_company = defaultdict(lambda: self.env['stock.warehouse.orderpoint'])
orderpoints_context_by_company = defaultdict(dict)
for move in self:
orderpoint = self.env['stock.warehouse.orderpoint'].search([
('product_id', '=', move.product_id.id),
@@ -1814,8 +1819,12 @@ class StockMove(models.Model):
], limit=1)
if orderpoint:
orderpoints_by_company[orderpoint.company_id] |= orderpoint
if orderpoint and move.product_qty > orderpoint.product_min_qty and move.origin:
orderpoints_context_by_company[orderpoint.company_id].setdefault(orderpoint.id, [])
orderpoints_context_by_company[orderpoint.company_id][orderpoint.id].append(move.origin)
for company, orderpoints in orderpoints_by_company.items():
orderpoints._procure_orderpoint_confirm(company_id=company, raise_user_error=False)
orderpoints.with_context(origins=orderpoints_context_by_company[company])._procure_orderpoint_confirm(
company_id=company, raise_user_error=False)
def _trigger_assign(self):
""" Check for and trigger action_assign for confirmed/partially_available moves related to done moves.
+6 -1
View File
@@ -482,12 +482,17 @@ class StockWarehouseOrderpoint(models.Model):
while orderpoints_batch:
procurements = []
for orderpoint in orderpoints_batch:
origins = orderpoint.env.context.get('origins', {}).get(orderpoint.id, False)
if origins:
origin = '%s - %s' % (orderpoint.display_name, ','.join(origins))
else:
origin = orderpoint.name
if float_compare(orderpoint.qty_to_order, 0.0, precision_rounding=orderpoint.product_uom.rounding) == 1:
date = datetime.combine(orderpoint.lead_days_date, time.min)
values = orderpoint._prepare_procurement_values(date=date)
procurements.append(self.env['procurement.group'].Procurement(
orderpoint.product_id, orderpoint.qty_to_order, orderpoint.product_uom,
orderpoint.location_id, orderpoint.name, orderpoint.name,
orderpoint.location_id, orderpoint.name, origin,
orderpoint.company_id, values))
try:
+1 -1
View File
@@ -199,7 +199,7 @@ class ProductProduct(models.Model):
if rounding_error:
# If it is bigger than the (smallest number of the currency * quantity) / 2,
# then it isn't a rounding error but a stock valuation error, we shouldn't fix it under the hood ...
if abs(rounding_error) <= (abs(quantity) * currency.rounding) / 2:
if abs(rounding_error) <= max((abs(quantity) * currency.rounding) / 2, currency.rounding):
vals['value'] += rounding_error
vals['rounding_adjustment'] = '\nRounding Adjustment: %s%s %s' % (
'+' if rounding_error > 0 else '',
@@ -554,6 +554,22 @@ class TestStockValuationAVCO(TestStockValuationCommon):
self.assertEqual(self.product1.value_svl, 0)
def test_rounding_svl_4(self):
"""
The first 2 In moves result in a rounded standard_price at 3.4943, which is rounded at 3.49.
This test ensures that no rounding error is generated with small out quantities.
"""
self.product1.categ_id.property_cost_method = 'average'
self._make_in_move(self.product1, 2, unit_cost=4.63)
self._make_in_move(self.product1, 5, unit_cost=3.04)
self.assertEqual(self.product1.standard_price, 3.49)
for _ in range(70):
self._make_out_move(self.product1, 0.1)
self.assertEqual(self.product1.quantity_svl, 0)
self.assertEqual(self.product1.value_svl, 0)
def test_return_delivery_2(self):
self.product1.write({"standard_price": 1})
move1 = self._make_out_move(self.product1, 10, create_picking=True, force_assign=True)
@@ -48,8 +48,12 @@ const TableOfContent = publicWidget.Widget.extend({
this.$target.find('.s_table_of_content_navbar').css('maxHeight', isHorizontalNavbar ? '' : `calc(100vh - ${position + 40}px)`);
if (this.previousPosition !== position) {
// The scrollSpy must be destroyed before calling it again.
// Otherwise the call has no effect.
this.$scrollingElement.scrollspy('dispose');
// Otherwise the call has no effect. We also need to be sure that
// a scrollSpy instance exists to avoid targeting elements outside
// the table of content navbar on scrollSpy methods.
if (this.$scrollingElement.data('bs.scrollspy')) {
this.$scrollingElement.scrollspy('dispose');
}
this.$scrollingElement.scrollspy({
target: '.s_table_of_content_navbar',
method: 'offset',