[PATCH] Upstream patch - 25012023

This commit is contained in:
Parthiv Patel committed 2023-01-25 08:38:21 +00:00
1 parent f261ba8343
commit ace68abdca
9 files changed
+69 -14

No files matched your search

+3 -6
View File
@@ -20,12 +20,9 @@ class CouponRule(models.Model):
('tax_included', 'Tax Included'),
('tax_excluded', 'Tax Excluded')], default="tax_excluded")
@api.constrains('rule_date_to', 'rule_date_from')
def _check_rule_date_from(self):
if any(applicability for applicability in self
if applicability.rule_date_to and applicability.rule_date_from
and applicability.rule_date_to < applicability.rule_date_from):
raise ValidationError(_('The start date must be before the end date'))
_sql_constraints = [
('check_coupon_rule_dates', 'check(rule_date_from < rule_date_to)', 'The start date must be before the end date!'),
]
@api.constrains('rule_minimum_amount')
def _check_rule_minimum_amount(self):
+3 -2
View File
@@ -213,11 +213,12 @@ class EventMailRegistration(models.Model):
author = company.partner_id
elif self.env.user.email:
author = self.env.user
email_values = {
'email_from': author.email_formatted,
'author_id': author.id,
}
if not reg_mail.scheduler_id.template_id.email_from:
email_values['email_from'] = author.email_formatted
reg_mail.scheduler_id.template_id.send_mail(reg_mail.registration_id.id, email_values=email_values)
todo.write({'mail_sent': True})
+2 -2
View File
@@ -22,6 +22,6 @@ class RepairOrder(models.Model):
def _compute_l10n_de_document_title(self):
for record in self:
if record.state == 'draft':
record.l10n_de_document_title = _("Repair Order")
else:
record.l10n_de_document_title = _("Repair Quotation")
else:
record.l10n_de_document_title = _("Repair Order")
@@ -45,7 +45,9 @@
<tbody>
<tr t-foreach="o.line_ids" t-as="line_ids">
<td>
[ <span t-field="line_ids.product_id.code"/> ]
<t t-if="line_ids.product_id.code"><!--internal reference exists-->
[ <span t-field="line_ids.product_id.code"/> ]
</t>
<span t-field="line_ids.product_id.name"/>
</td>
<td class="text-right">
+1 -1
View File
@@ -127,7 +127,7 @@ class SendSMS(models.TransientModel):
continue
records.ensure_one()
res = records._sms_get_recipients_info(force_field=composer.number_field_name, partner_fallback=False)
composer.recipient_single_description = res[records.id]['partner'].name or records.display_name
composer.recipient_single_description = res[records.id]['partner'].name or records._sms_get_default_partners().display_name
composer.recipient_single_number = res[records.id]['number'] or ''
if not composer.recipient_single_number_itf:
composer.recipient_single_number_itf = res[records.id]['number'] or ''
+12
View File
@@ -761,6 +761,18 @@ class ProductTemplate(models.Model):
return res
def write(self, vals):
if 'company_id' in vals and vals['company_id']:
products_changing_company = self.filtered(lambda product: product.company_id.id != vals['company_id'])
if products_changing_company:
# Forbid changing a product's company when quant(s) exist in another company.
quant = self.env['stock.quant'].sudo().search([
('product_id', 'in', products_changing_company.product_variant_ids.ids),
('company_id', '!=', vals['company_id']),
('quantity', '!=', 0),
], order=None, limit=1)
if quant:
raise UserError(_("This product's company cannot be changed as long as there are quantities of it belonging to another company."))
if 'uom_id' in vals:
new_uom = self.env['uom.uom'].browse(vals['uom_id'])
updated = self.filtered(lambda template: template.uom_id != new_uom)
+28
View File
@@ -5,6 +5,7 @@
# Copyright 2015 Camptocamp SA
from flectra.addons.stock.tests.common2 import TestStockCommon
from flectra.exceptions import UserError
from flectra.tests.common import Form
@@ -105,6 +106,33 @@ class TestVirtualAvailable(TestStockCommon):
self.product_3.active = False
self.assertFalse(orderpoint.active)
def test_change_product_company(self):
""" Checks we can't change the product's company if this product has
quant in another company. """
company1 = self.env.ref('base.main_company')
company2 = self.env['res.company'].create({'name': 'Second Company'})
product = self.env['product.product'].create({
'name': 'Product [TEST - Change Company]',
'type': 'product',
})
# Creates a quant for productA in the first company.
self.env['stock.quant'].create({
'product_id': product.id,
'product_uom_id': self.uom_unit.id,
'location_id': self.location_1.id,
'quantity': 7,
'reserved_quantity': 0,
})
# Assigns a company: should be OK for company1 but should raise an error for company2.
product.company_id = company1.id
with self.assertRaises(UserError):
product.company_id = company2.id
# Checks we can assing company2 for the product once there is no more quant for it.
quant = self.env['stock.quant'].search([('product_id', '=', product.id)])
quant.quantity = 0
self.env['stock.quant']._unlink_zero_quants()
product.company_id = company2.id # Should work this time.
def test_search_qty_available(self):
product = self.env['product.product'].create({
'name': 'Brand new product',
@@ -120,6 +120,21 @@ class TestSMSComposerComment(TestMailFullCommon, TestRecipients):
self.assertSMSNotification([{'partner': self.test_record.customer_id, 'number': self.test_record.mobile_nbr}], 'Dear %s this is an SMS.' % self.test_record.display_name, messages)
def test_composer_default_recipient(self):
self.test_record.write({
'phone_nbr': '0123456789',
})
with self.with_user('employee'):
composer = self.env['sms.composer'].with_context(
default_res_model='mail.test.sms', default_res_id=self.test_record.id,
).create({
'body': self._test_body,
'number_field_name': 'phone_nbr',
})
self.assertFalse(composer.recipient_single_valid)
self.assertEqual(composer.recipient_single_description, self.test_record.customer_id.display_name)
def test_composer_internals(self):
with self.with_user('employee'):
composer = self.env['sms.composer'].with_context(
+2 -2
View File
@@ -13,8 +13,8 @@
</a>
<br/><br/>
Example of rule:<br/>
<code class='ml-4'>Disallow: /web/login</code><br/>
<code class='ml-4'>Allow: *</code>
<code t-translation="off" class='ml-4'>Disallow: /web/login</code><br/>
<code t-translation="off" class='ml-4'>Allow: *</code>
</small>
<footer>
<button string="Save" name="action_save" type="object" class="oe_highlight"/>