This commit is contained in:
gsinghpal
2026-06-03 19:50:45 -04:00
parent 837198fc8a
commit 2f8b6b3ae0
5 changed files with 169 additions and 25 deletions

View File

@@ -346,15 +346,30 @@ class ResUsers(models.Model):
string='Login Audit Count',
compute='_compute_x_fc_login_audit_count',
)
# NON-STORED on purpose — do NOT re-add store=True.
#
# These were store=True computed-from-the-audit-One2many. That meant every
# successful-login audit row (written through an INDEPENDENT
# registry.cursor(), see _fc_record_login_event) forced a recompute that
# flushed a write-back onto THIS res_users row. During portal-invitation
# acceptance the request has already locked that row (auth_signup just set
# the password in the same transaction), so the audit cursor's write-back
# blocked on the request's own row lock while the request's Python blocked
# waiting for the audit cursor — a self-deadlock Postgres cannot detect
# (the holder shows 'idle in transaction', not lock-waiting). Workers
# wedged for up to limit_time_real (20 min) and odoo-westin went
# unresponsive every time an invite was accepted (issue 2026-06-03).
#
# Keeping them non-stored means creating an audit row never touches
# res_users. They compute on read (display-only on the user form). The
# regression guard is tests.test_last_login_fields_not_stored.
x_fc_last_successful_login = fields.Datetime(
string='Last Successful Login',
compute='_compute_x_fc_last_successful_login',
store=True,
)
x_fc_last_login_ip = fields.Char(
string='Last Login IP', size=45,
compute='_compute_x_fc_last_successful_login',
store=True,
)
@api.depends('x_fc_login_audit_ids')

View File

@@ -303,6 +303,54 @@ class TestFusionLoginAuditModel(TransactionCase):
self.assertGreaterEqual(user.x_fc_login_audit_count, 1)
self.assertEqual(user.x_fc_last_login_ip, '198.51.100.42')
def test_last_login_fields_not_stored(self):
"""Regression guard for the 2026-06-03 invitation-acceptance hang.
x_fc_last_successful_login / x_fc_last_login_ip MUST stay non-stored.
When they were store=True (computed from the audit One2many), creating
the success audit row through the independent registry cursor forced a
write-back onto the very res_users row the request had already locked
(auth_signup had just set the password) -> a self-deadlock Postgres
cannot see (the holder shows 'idle in transaction'). Workers wedged for
up to limit_time_real and odoo-westin became unresponsive whenever an
invitation was accepted. Non-stored means audit-row creation never
touches res_users, so the deadlock cannot form.
"""
fields_ = self.env['res.users']._fields
self.assertFalse(
fields_['x_fc_last_successful_login'].store,
"x_fc_last_successful_login must be non-stored (see docstring)")
self.assertFalse(
fields_['x_fc_last_login_ip'].store,
"x_fc_last_login_ip must be non-stored (see docstring)")
def test_audit_row_create_does_not_write_res_users(self):
"""Creating a login-audit row must not write the linked res_users row.
This is the behavioural half of the deadlock guard: with the fields
non-stored, inserting an audit row for a user leaves that user's
write_date untouched (no recompute -> no res_users UPDATE -> nothing
to contend with the request's own row lock).
"""
user = self.env['res.users'].sudo().create({
'name': 'NoWriteback Tester',
'login': 'nowriteback-tester@example.com',
'password': 'nowriteback-tester-pw-1',
})
user.flush_recordset()
before = user.write_date
self.env['fusion.login.audit'].sudo().create({
'user_id': user.id,
'attempted_login': user.login,
'result': 'success',
'database': self.env.cr.dbname,
'ip_address': '198.51.100.7',
})
user.invalidate_recordset()
self.assertEqual(
user.write_date, before,
"Audit-row create must not write back to res_users")
def test_action_view_login_audit_returns_window_action(self):
"""The smart-button action returns an act_window scoped to this user."""
user = self.env['res.users'].sudo().create({

View File

@@ -3,7 +3,7 @@
# License OPL-1 (Odoo Proprietary License v1.0)
{
'name': 'Fusion Reports — Templates',
'version': '19.0.1.2.0',
'version': '19.0.1.3.0',
'category': 'Tools/Reports',
'summary': 'Branded PDF templates for Quotation, Sales Order, Invoice, Delivery, Purchase Order, and Payment Receipt.',
'description': """

View File

@@ -78,14 +78,18 @@
</tbody>
</table>
<t t-set="has_discount" t-value="any(l.discount for l in doc.invoice_line_ids)"/>
<t t-set="col_count" t-value="8 if has_discount else 7"/>
<t t-set="total_discount" t-value="sum(l.price_unit * l.quantity * l.discount / 100.0 for l in doc.invoice_line_ids if not l.display_type or l.display_type == 'product')"/>
<table class="bordered">
<thead>
<tr>
<th style="width: 12%;">SKU</th>
<th class="text-start" style="width: 40%;">DESCRIPTION</th>
<th style="width: 8%;">QTY</th>
<th style="width: 8%;">UOM</th>
<th style="width: 12%;">UNIT PRICE</th>
<th style="width: 11%;">SKU</th>
<th class="text-start" style="width: 33%;">DESCRIPTION</th>
<th style="width: 7%;">QTY</th>
<th style="width: 7%;">UOM</th>
<th style="width: 13%;">UNIT PRICE</th>
<th t-if="has_discount" style="width: 9%;">DISCOUNT</th>
<th style="width: 8%;">TAX</th>
<th style="width: 12%;">AMOUNT</th>
</tr>
@@ -93,10 +97,10 @@
<tbody>
<t t-foreach="doc.invoice_line_ids" t-as="line">
<t t-if="line.display_type == 'line_section'">
<tr class="section-row"><td colspan="7"><strong t-field="line.name"/></td></tr>
<tr class="section-row"><td t-att-colspan="col_count"><strong t-field="line.name"/></td></tr>
</t>
<t t-elif="line.display_type == 'line_note'">
<tr class="note-row"><td colspan="7"><span t-field="line.name"/></td></tr>
<tr class="note-row"><td t-att-colspan="col_count"><span t-field="line.name"/></td></tr>
</t>
<t t-elif="line.display_type == 'product' or not line.display_type">
<tr>
@@ -109,6 +113,10 @@
<td class="text-end">
<span t-field="line.price_unit" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
<td t-if="has_discount" class="text-center">
<t t-if="line.discount"><span t-esc="line.discount"/>%</t>
<t t-else="">-</t>
</td>
<td class="text-center">
<t t-esc="', '.join([(tax.invoice_label or tax.name) for tax in line.tax_ids]) or '-'"/>
</td>
@@ -139,9 +147,23 @@
<tr>
<td style="min-width: 150px;">Subtotal</td>
<td class="text-end" style="min-width: 110px;">
<span t-field="doc.amount_untaxed" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
<span t-out="doc.amount_untaxed + total_discount" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
</tr>
<t t-if="has_discount">
<tr>
<td>Discount</td>
<td class="text-end">
<span t-out="-total_discount" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
</tr>
<tr>
<td>Net Amount</td>
<td class="text-end">
<span t-field="doc.amount_untaxed" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
</tr>
</t>
<tr>
<td>Taxes</td>
<td class="text-end">
@@ -254,25 +276,29 @@
</tbody>
</table>
<t t-set="has_discount" t-value="any(l.discount for l in doc.invoice_line_ids)"/>
<t t-set="col_count" t-value="8 if has_discount else 7"/>
<t t-set="total_discount" t-value="sum(l.price_unit * l.quantity * l.discount / 100.0 for l in doc.invoice_line_ids if not l.display_type or l.display_type == 'product')"/>
<table class="bordered">
<thead>
<tr>
<th style="width: 10%;">SKU</th>
<th class="text-start" style="width: 40%;">DESCRIPTION</th>
<th class="text-start" style="width: 32%;">DESCRIPTION</th>
<th style="width: 8%;">QTY</th>
<th style="width: 8%;">UOM</th>
<th style="width: 12%;">UNIT PRICE</th>
<th t-if="has_discount" style="width: 10%;">DISCOUNT</th>
<th style="width: 10%;">TAX</th>
<th style="width: 12%;">AMOUNT</th>
<th style="width: 10%;">AMOUNT</th>
</tr>
</thead>
<tbody>
<t t-foreach="doc.invoice_line_ids" t-as="line">
<t t-if="line.display_type == 'line_section'">
<tr class="section-row"><td colspan="7"><strong t-field="line.name"/></td></tr>
<tr class="section-row"><td t-att-colspan="col_count"><strong t-field="line.name"/></td></tr>
</t>
<t t-elif="line.display_type == 'line_note'">
<tr class="note-row"><td colspan="7"><span t-field="line.name"/></td></tr>
<tr class="note-row"><td t-att-colspan="col_count"><span t-field="line.name"/></td></tr>
</t>
<t t-elif="line.display_type == 'product' or not line.display_type">
<tr>
@@ -285,6 +311,10 @@
<td class="text-end">
<span t-field="line.price_unit" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
<td t-if="has_discount" class="text-center">
<t t-if="line.discount"><span t-esc="line.discount"/>%</t>
<t t-else="">-</t>
</td>
<td class="text-center">
<t t-esc="', '.join([(tax.invoice_label or tax.name) for tax in line.tax_ids]) or '-'"/>
</td>
@@ -315,9 +345,23 @@
<tr>
<td style="min-width: 200px;">Subtotal</td>
<td class="text-end" style="min-width: 150px;">
<span t-field="doc.amount_untaxed" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
<span t-out="doc.amount_untaxed + total_discount" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
</tr>
<t t-if="has_discount">
<tr>
<td>Discount</td>
<td class="text-end">
<span t-out="-total_discount" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
</tr>
<tr>
<td>Net Amount</td>
<td class="text-end">
<span t-field="doc.amount_untaxed" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
</tr>
</t>
<tr>
<td>Taxes</td>
<td class="text-end">

View File

@@ -64,14 +64,18 @@
</tbody>
</table>
<t t-set="has_discount" t-value="any(l.discount for l in doc.order_line)"/>
<t t-set="col_count" t-value="8 if has_discount else 7"/>
<t t-set="total_discount" t-value="sum(l.price_unit * l.product_uom_qty * l.discount / 100.0 for l in doc.order_line if not l.display_type or l.display_type == 'product')"/>
<table class="bordered">
<thead>
<tr>
<th style="width: 12%;">SKU</th>
<th class="text-start" style="width: 38%;">DESCRIPTION</th>
<th style="width: 8%;">QTY</th>
<th style="width: 8%;">UOM</th>
<th style="width: 14%;">UNIT PRICE</th>
<th style="width: 11%;">SKU</th>
<th class="text-start" style="width: 33%;">DESCRIPTION</th>
<th style="width: 7%;">QTY</th>
<th style="width: 7%;">UOM</th>
<th style="width: 13%;">UNIT PRICE</th>
<th t-if="has_discount" style="width: 9%;">DISCOUNT</th>
<th style="width: 8%;">TAX</th>
<th style="width: 12%;">AMOUNT</th>
</tr>
@@ -79,10 +83,10 @@
<tbody>
<t t-foreach="doc.order_line" t-as="line">
<t t-if="line.display_type == 'line_section'">
<tr class="section-row"><td colspan="7"><strong t-field="line.name"/></td></tr>
<tr class="section-row"><td t-att-colspan="col_count"><strong t-field="line.name"/></td></tr>
</t>
<t t-elif="line.display_type == 'line_note'">
<tr class="note-row"><td colspan="7"><span t-field="line.name"/></td></tr>
<tr class="note-row"><td t-att-colspan="col_count"><span t-field="line.name"/></td></tr>
</t>
<t t-elif="not line.display_type or line.display_type == 'product'">
<tr>
@@ -101,6 +105,10 @@
<td class="text-end">
<span t-field="line.price_unit" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
<td t-if="has_discount" class="text-center">
<t t-if="line.discount"><span t-esc="line.discount"/>%</t>
<t t-else="">-</t>
</td>
<td class="text-center">
<t t-esc="', '.join([(tax.invoice_label or tax.name) for tax in line.tax_ids]) or '-'"/>
</td>
@@ -125,9 +133,23 @@
<tr>
<td style="min-width: 150px;">Subtotal</td>
<td class="text-end" style="min-width: 110px;">
<span t-field="doc.amount_untaxed" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
<span t-out="doc.amount_untaxed + total_discount" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
</tr>
<t t-if="has_discount">
<tr>
<td>Discount</td>
<td class="text-end">
<span t-out="-total_discount" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
</tr>
<tr>
<td>Net Amount</td>
<td class="text-end">
<span t-field="doc.amount_untaxed" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
</tr>
</t>
<tr>
<td>Taxes</td>
<td class="text-end">
@@ -236,6 +258,7 @@
<t t-set="has_discount" t-value="any(l.discount for l in doc.order_line)"/>
<t t-set="col_count" t-value="8 if has_discount else 7"/>
<t t-set="total_discount" t-value="sum(l.price_unit * l.product_uom_qty * l.discount / 100.0 for l in doc.order_line if not l.display_type or l.display_type == 'product')"/>
<table class="bordered">
<thead>
<tr>
@@ -302,9 +325,23 @@
<tr>
<td style="min-width: 200px;">Subtotal</td>
<td class="text-end" style="min-width: 150px;">
<span t-field="doc.amount_untaxed" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
<span t-out="doc.amount_untaxed + total_discount" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
</tr>
<t t-if="has_discount">
<tr>
<td>Discount</td>
<td class="text-end">
<span t-out="-total_discount" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
</tr>
<tr>
<td>Net Amount</td>
<td class="text-end">
<span t-field="doc.amount_untaxed" t-options='{"widget": "monetary", "display_currency": doc.currency_id}'/>
</td>
</tr>
</t>
<tr>
<td>Taxes</td>
<td class="text-end">