[PATCH] Upstream patch - 13032023

This commit is contained in:
Parthiv Patel
2023-03-13 08:35:11 +00:00
parent 6bbf3f8669
commit dfc26c1fb0
6 changed files with 28 additions and 6 deletions
@@ -46,7 +46,7 @@
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box" id="synchronize_web_mobile_setting">
<div class="col-12 col-lg-6 o_setting_box" id="synchronize_web_mobile_setting" invisible="1">
<div class="o_setting_left_pane">
<field name="module_project_timesheet_synchro" widget="upgrade_boolean"/>
</div>
+2 -2
View File
@@ -2,7 +2,7 @@
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
from flectra import api, fields, models, _
from flectra.exceptions import AccessError, UserError
from flectra.exceptions import UserError, ValidationError
from flectra.tools import float_compare, float_round
from flectra.osv import expression
@@ -125,7 +125,7 @@ class MrpUnbuild(models.Model):
@api.constrains('product_qty')
def _check_qty(self):
if self.product_qty <= 0:
raise ValueError(_('Unbuild Order product quantity has to be strictly positive.'))
raise ValidationError(_('Unbuild Order product quantity has to be strictly positive.'))
@api.model
def create(self, vals):
+9
View File
@@ -204,6 +204,15 @@ class StockQuant(models.Model):
return super(StockQuant, self).write(vals)
return super(StockQuant, self).write(vals)
def unlink(self):
if not self.env.is_superuser():
# normally we would allow any user with permission to unlink, but inventory_quantity can only be set by stock_manager
if not self.user_has_groups('stock.group_stock_manager'):
raise UserError(_("Quants are auto-deleted when appropriate. If you must manually delete them, please ask a stock manager to do it."))
self = self.with_context(inventory_mode=True)
self.inventory_quantity = 0
return super().unlink()
def action_view_stock_moves(self):
self.ensure_one()
action = self.env["ir.actions.actions"]._for_xml_id("stock.stock_move_line_action")
+2 -2
View File
@@ -505,7 +505,7 @@ class StockQuant(SavepointCase):
})
with self.assertRaises(AccessError):
quant.with_user(self.demo_user).write({'quantity': 2.0})
with self.assertRaises(AccessError):
with self.assertRaises(UserError):
quant.with_user(self.demo_user).unlink()
self.env = self.env(user=self.stock_user)
@@ -517,7 +517,7 @@ class StockQuant(SavepointCase):
})
with self.assertRaises(AccessError):
quant.with_user(self.demo_user).write({'quantity': 2.0})
with self.assertRaises(AccessError):
with self.assertRaises(UserError):
quant.with_user(self.demo_user).unlink()
def test_in_date_1(self):
+1
View File
@@ -123,6 +123,7 @@
<field name="date_done"/>
<field name="product_id" readonly="1"/>
<field name="scrap_qty"/>
<field name="product_uom_category_id" invisible="1"/>
<field name="product_uom_id" groups="uom.group_uom"/>
<field name="location_id" options="{'no_create': True}" groups="stock.group_stock_multi_locations"/>
<field name="scrap_location_id" options="{'no_create': True}" groups="stock.group_stock_multi_locations"/>
@@ -3932,6 +3932,18 @@ registry.BackgroundShape = SnippetOptionWidget.extend({
}
return this._super.apply(this, arguments);
},
/**
* @override
*/
onBuilt() {
// Flip classes should no longer be used but are still present in some
// theme snippets.
if (this.$target[0].querySelector('.o_we_flip_x, .o_we_flip_y')) {
this._handlePreviewState(false, () => {
return {flip: this._getShapeData().flip};
});
}
},
//--------------------------------------------------------------------------
// Options
@@ -4203,7 +4215,7 @@ registry.BackgroundShape = SnippetOptionWidget.extend({
}
const searchParams = Object.entries(colors)
.map(([colorName, colorValue]) => {
const encodedCol = encodeURIComponent(colorValue);
const encodedCol = encodeURIComponent(normalizeColor(colorValue));
return `${colorName}=${encodedCol}`;
});
if (flip.length) {