mirror of
https://gitlab.com/flectra-hq/flectra.git
synced 2026-08-19 01:34:43 -05:00
Merge branch 'master-upstream-patch-12102022' into 'master'
[PATCH] Upstream patch - 12102022 See merge request flectra-hq/flectra!827
This commit is contained in:
@@ -8,8 +8,7 @@ class UoM(models.Model):
|
||||
|
||||
def _get_unece_code(self):
|
||||
""" Returns the UNECE code used for international trading for corresponding to the UoM as per
|
||||
https://unece.org/fileadmin/DAM/cefact/recommendations/bkup_htm/add2d.htm.
|
||||
"""
|
||||
https://unece.org/fileadmin/DAM/cefact/recommendations/rec20/rec20_rev3_Annex2e.pdf"""
|
||||
mapping = {
|
||||
'uom.product_uom_unit': 'C62',
|
||||
'uom.product_uom_dozen': 'DZN',
|
||||
|
||||
@@ -17,6 +17,11 @@ class AccountAnalyticLine(models.Model):
|
||||
result = super(AccountAnalyticLine, self).default_get(field_list)
|
||||
if 'encoding_uom_id' in field_list:
|
||||
result['encoding_uom_id'] = self.env.company.timesheet_encode_uom_id.id
|
||||
employee_id = self._context.get('default_employee_id')
|
||||
if employee_id:
|
||||
employee = self.env['hr.employee'].browse(employee_id)
|
||||
if 'user_id' not in result or employee.user_id.id != result.get('user_id'):
|
||||
result['user_id'] = employee.user_id.id
|
||||
if not self.env.context.get('default_employee_id') and 'employee_id' in field_list and result.get('user_id'):
|
||||
result['employee_id'] = self.env['hr.employee'].search([('user_id', '=', result['user_id']), ('company_id', '=', result.get('company_id', self.env.company.id))], limit=1).id
|
||||
return result
|
||||
|
||||
@@ -458,3 +458,35 @@ class TestTimesheet(TestCommonTimesheet):
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
timesheet.employee_id = self.empl_employee2
|
||||
|
||||
def test_check_timesheet_user(self):
|
||||
""" Test Check whether the timesheet user is correct or not.
|
||||
|
||||
Part 1: Test Case:
|
||||
----------
|
||||
1) Create employee without user
|
||||
2) Create timesheet
|
||||
3) Check the user of the timesheet
|
||||
|
||||
Part 2: Test Case:
|
||||
----------
|
||||
3) Create a timesheet of the employee linked to the user
|
||||
4) Check the user of the timesheet
|
||||
"""
|
||||
|
||||
Timesheet = self.env['account.analytic.line']
|
||||
|
||||
emp_without_user = self.env['hr.employee'].create({
|
||||
'name': 'Empl Employee',
|
||||
})
|
||||
without_user_timesheet = Timesheet.with_context(default_employee_id=emp_without_user.id).create({
|
||||
'project_id': self.project_customer.id,
|
||||
'unit_amount': 8.0,
|
||||
})
|
||||
self.assertFalse(without_user_timesheet.user_id, 'User is not set in timesheet.')
|
||||
|
||||
with_user_timesheet = Timesheet.with_context(default_employee_id=self.empl_employee.id).create({
|
||||
'project_id': self.project_customer.id,
|
||||
'unit_amount': 8.0,
|
||||
})
|
||||
self.assertEqual(with_user_timesheet.user_id, self.user_employee, 'User Employee is set in timesheet.')
|
||||
|
||||
@@ -887,6 +887,12 @@ class WebsiteSale(http.Controller):
|
||||
return_url= '/shop/payment/validate',
|
||||
bootstrap_formatting= True
|
||||
)
|
||||
if order.partner_id.company_id and order.partner_id.company_id.id != order.company_id.id:
|
||||
values['errors'].append(
|
||||
(_('Sorry, we are unable to find a Payment Method'),
|
||||
_('No payment method is available for your current order. '
|
||||
'Please contact us for more information.')))
|
||||
return values
|
||||
|
||||
domain = expression.AND([
|
||||
['&', ('state', 'in', ['enabled', 'test']), ('company_id', '=', order.company_id.id)],
|
||||
|
||||
Reference in New Issue
Block a user