[PATCH] Upstream patch - 04102022

This commit is contained in:
Parthiv Patel
2022-10-04 06:18:49 +00:00
parent 6aa3eaaa5c
commit 2266af029a
8 changed files with 82 additions and 6 deletions

View File

@@ -23,7 +23,10 @@
<div id="informations" class="row mt-4 mb-4">
<div class="col-auto col-3 mw-100 mb-2" t-if="o.invoice_date" name="invoice_date">
<strong>Invoice Date:</strong>
<t t-if="o.move_type == 'out_invoice'"><strong>Invoice Date:</strong></t>
<t t-if="o.move_type == 'out_refund'"><strong>Credit Note Date:</strong></t>
<t t-if="o.move_type == 'out_receipt'"><strong>Receipt Date:</strong></t>
<t t-else=""><strong>Date:</strong></t>
<p class="m-0" t-field="o.invoice_date"/>
</div>
<div class="col-auto col-3 mw-100 mb-2" t-if="o.invoice_date_due and o.move_type == 'out_invoice' and o.state == 'posted'" name="due_date">

View File

@@ -146,10 +146,10 @@ function factory(dependencies) {
/**
* Opens the most appropriate view that is a profile for this employee.
*/
async openProfile() {
async openProfile(model = 'hr.employee.public') {
return this.env.messaging.openDocument({
id: this.id,
model: 'hr.employee.public',
model: model,
});
}

View File

@@ -27,7 +27,7 @@ registerInstancePatchModel('mail.messaging', 'hr/static/src/models/messaging/mes
async openProfile({ id, model }) {
if (model === 'hr.employee' || model === 'hr.employee.public') {
const employee = this.env.models['hr.employee'].insert({ id });
return employee.openProfile();
return employee.openProfile(model);
}
return this._super(...arguments);
},

View File

@@ -78,6 +78,8 @@ class MrpProduction(models.Model):
def button_mark_done(self):
res = super(MrpProduction, self).button_mark_done()
for order in self:
if order.state != 'done':
continue
order._costs_generate()
return res

View File

@@ -190,6 +190,63 @@ class TestMrpAccount(TestMrpCommon):
# 1 table head at 20 + 4 table leg at 15 + 4 bolt at 10 + 10 screw at 10 + 1*20 (extra cost)
self.assertEqual(move_value, 141, 'Thing should have the correct price')
def test_generate_analytic_account(self):
"""
Suppose a workcenter with a cost and an analytic account. A MO is
processed and one of the components has been consumed more than
expected. The test ensures that the analytic account line will be
generated only once.
"""
analytic_account = self.env['account.analytic.account'].create({'name': 'Super Analytic Account'})
cost_per_hour = 100
workcenter = self.env['mrp.workcenter'].create({
'name': 'SuperWorkcenter',
'costs_hour': cost_per_hour,
'costs_hour_account_id': analytic_account.id,
})
bom = self.env['mrp.bom'].create({
'product_tmpl_id': self.product_2.product_tmpl_id.id,
'product_qty': 1,
'bom_line_ids': [(0, 0, {
'product_id': self.product_1.id,
'product_qty': 1,
})],
'operation_ids': [(0, 0, {
'name': 'Super Operation',
'workcenter_id': workcenter.id,
})],
})
mo = self.env['mrp.production'].create({
'name': 'Super MO',
'product_id': self.product_2.id,
'product_uom_id': self.product_2.uom_id.id,
'product_qty': 1,
'bom_id': bom.id,
})
mo._onchange_move_raw()
mo._onchange_move_finished()
mo._onchange_workorder_ids()
mo.action_confirm()
duration = 30
mo.qty_producing = 1
mo.workorder_ids.duration = duration
mo.move_raw_ids.move_line_ids.qty_done = 2
action = mo.button_mark_done()
self.assertNotEqual(mo.state, 'done')
self.assertFalse(analytic_account.line_ids)
warning = Form(self.env['mrp.consumption.warning'].with_context(**action['context']))
warning = warning.save()
warning.action_confirm()
self.assertEqual(mo.state, 'done')
self.assertEqual(analytic_account.line_ids.amount, - duration / 60 * cost_per_hour)
@tagged("post_install", "-at_install")
class TestMrpAccountMove(TestAccountMove):

View File

@@ -86,7 +86,7 @@ class PaymentAcquirer(models.Model):
'partner': self.alipay_merchant_partner_id,
'return_url': urls.url_join(base_url, AlipayController._return_url),
'subject': values.get('reference'),
'total_fee': values.get('amount') + values.get('fees'),
'total_fee': '%.2f' % (values.get('amount') + values.get('fees')),
})
if self.alipay_payment_method == 'standard_checkout':
alipay_tx_values.update({

View File

@@ -983,7 +983,7 @@ class ResourceResource(models.Model):
calendar_mapping[resource.calendar_id] |= resource
for calendar, resources in calendar_mapping.items():
resources_unavailable_intervals = calendar._unavailable_intervals_batch(start_datetime, end_datetime, resources)
resources_unavailable_intervals = calendar._unavailable_intervals_batch(start_datetime, end_datetime, resources, tz=timezone(calendar.tz))
resource_mapping.update(resources_unavailable_intervals)
return resource_mapping

View File

@@ -2,6 +2,7 @@
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
from datetime import date, datetime
from freezegun import freeze_time
from pytz import timezone, utc
from flectra import fields
@@ -1206,3 +1207,16 @@ class TestTimezones(TestResourceCommon):
(date(2018, 4, 12), 8),
(date(2018, 4, 13), 8),
])
@freeze_time("2022-09-21 15:30:00", tz_offset=-10)
def test_unavailable_intervals(self):
resource = self.env['resource.resource'].create({
'name': 'resource',
'tz': self.tz3,
})
intervals = resource._get_unavailable_intervals(datetime(2022, 9, 21), datetime(2022, 9, 22))
self.assertEqual(list(intervals.values())[0], [
(datetime(2022, 9, 21, 0, 0, tzinfo=utc), datetime(2022, 9, 21, 6, 0, tzinfo=utc)),
(datetime(2022, 9, 21, 10, 0, tzinfo=utc), datetime(2022, 9, 21, 11, 0, tzinfo=utc)),
(datetime(2022, 9, 21, 15, 0, tzinfo=utc), datetime(2022, 9, 22, 0, 0, tzinfo=utc)),
])