Reviste Sucursales y arregla el alta que el admin general no podía hacer
La lista se reviste sobre la nativa —conserva la forma de una lista editable, así que no hay motivo para escribirla— y la ficha lleva arch propio, por el mismo criterio que Clientes: la vista anterior eran dos <group> planos y el diseño pide dos tarjetas con título, el código como pill, los usuarios como chips, el bloque del checador y un pie. Con dos aplicaciones seguidas, ese criterio deja de ser un caso y pasa a ser la regla en ADR-013. EL HALLAZGO DE LA FASE no es de revestimiento: un administrador general NO PODÍA DAR DE ALTA UNA SUCURSAL. El aprovisionador itera self.sudo() pero creaba con self.env, que es el entorno del usuario, así que se estrellaba con «You are not allowed to create 'Sequence'». Estaba documentado desde el principio como que corre con sudo, y a medias no lo era. No se había visto porque hasta hoy las sucursales solo las habían creado los datos demo y los tests, ambos como superusuario — que es justo la forma de prueba que ADR-016 describe: la que pasa porque nunca recorre el camino real. El test nuevo crea la sucursal como el rol que la crea de verdad. Las cuatro columnas que llena el sistema nunca son inputs (BRIEF §5.3): las pinta el widget beyond_al_guardar, que muestra el valor cuando existe y una leyenda gris mientras no, porque un campo readonly a secas se ve como una celda vacía y eso se lee como algo que a la persona se le olvidó. El mismo widget resuelve el copiar de la URL del kiosco, en la lista y en la ficha. Un choque del diseño que hay que decidir y queda decidido: en una lista editable el clic en un renglón lo pone a editar —es lo que la hace editable— así que no puede además abrir la ficha. Se conserva el alta de un renglón, que es contractual, y la ficha se abre con el control que Odoo trae para este caso. Lo que no era de Clientes sube a la capa del panel antes de escribir la segunda pantalla: el estilo de campo del diseño, el centrado de la tarjeta, el título de la miga en una línea y el pie de acciones, que además pierde el nombre de Clientes en la clase. ADR-016 recoge las cinco formas de prueba que pasan sin probar nada que esta fase y la anterior destaparon, con el caso real de cada una y cómo se detecta. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
317403fdf9
commit
d8706cc91d
18 files changed
+1028
-134
No files matched your search
@@ -0,0 +1,86 @@
|
||||
/** Part of Beyond. Collina Systems proprietary module. */
|
||||
import { Component } from "@odoo/owl";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { standardFieldProps } from "@web/views/fields/standard_field_props";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
|
||||
/**
|
||||
* A field the system fills in, never the person.
|
||||
*
|
||||
* BRIEF §5.3 asks that adding a branch be «as easy as adding a row»: the user
|
||||
* types name, address, city and phone, and the provisioner creates the code,
|
||||
* the warehouse, the point of sale and the kiosk URL on save. The design shows
|
||||
* those four columns in the new row as grey legends — «se asigna al guardar» —
|
||||
* and the wording matters less than the fact that THEY ARE NEVER INPUTS. A
|
||||
* readonly field in an editable list renders as an empty cell, which reads as
|
||||
* something the user forgot to fill in.
|
||||
*
|
||||
* This widget renders the value once it exists, and the legend while it does
|
||||
* not. It takes the legend from the view, so the same widget serves «se asigna
|
||||
* al guardar» for a code and «se crea al guardar» for a warehouse.
|
||||
*
|
||||
* <field name="code" widget="beyond_al_guardar"
|
||||
* options="{'leyenda': 'se asigna al guardar'}"/>
|
||||
*
|
||||
* With `copiar` it also offers to copy the value, which is what the kiosk URL
|
||||
* needs in the list: long, truncated, and useless if it cannot be copied.
|
||||
*/
|
||||
export class BeyondAlGuardar extends Component {
|
||||
static template = "beyond_base.AlGuardar";
|
||||
// Declaradas, no solo extraídas: OWL valida las props en desarrollo y
|
||||
// una clave no declarada tumba el componente entero con «unknown key».
|
||||
static props = {
|
||||
...standardFieldProps,
|
||||
leyenda: { type: String, optional: true },
|
||||
copiar: { type: Boolean, optional: true },
|
||||
};
|
||||
|
||||
setup() {
|
||||
this.notification = useService("notification");
|
||||
}
|
||||
|
||||
get valor() {
|
||||
const dato = this.props.record.data[this.props.name];
|
||||
if (!dato) {
|
||||
return "";
|
||||
}
|
||||
// Un many2one llega como registro; lo demás, tal cual.
|
||||
return typeof dato === "object" ? dato.display_name || "" : String(dato);
|
||||
}
|
||||
|
||||
get leyenda() {
|
||||
return this.props.leyenda || _t("se asigna al guardar");
|
||||
}
|
||||
|
||||
get puedeCopiar() {
|
||||
return this.props.copiar && !!this.valor;
|
||||
}
|
||||
|
||||
async copiar() {
|
||||
await navigator.clipboard.writeText(this.valor);
|
||||
this.notification.add(_t("Copiado"), { type: "success" });
|
||||
}
|
||||
}
|
||||
|
||||
registry.category("fields").add("beyond_al_guardar", {
|
||||
component: BeyondAlGuardar,
|
||||
displayName: _t("Lo asigna el sistema"),
|
||||
supportedTypes: ["char", "many2one"],
|
||||
supportedOptions: [
|
||||
{
|
||||
label: _t("Leyenda mientras no hay valor"),
|
||||
name: "leyenda",
|
||||
type: "string",
|
||||
},
|
||||
{
|
||||
label: _t("Ofrecer copiar el valor"),
|
||||
name: "copiar",
|
||||
type: "boolean",
|
||||
},
|
||||
],
|
||||
extractProps: ({ options }) => ({
|
||||
leyenda: options.leyenda,
|
||||
copiar: !!options.copiar,
|
||||
}),
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
<t t-name="beyond_base.AlGuardar">
|
||||
<span t-if="valor" class="beyond_al_guardar_valor" t-att-title="valor" t-esc="valor"/>
|
||||
<span t-else="" class="beyond_al_guardar_leyenda" t-esc="leyenda"/>
|
||||
<button t-if="puedeCopiar" class="beyond_al_guardar_copiar"
|
||||
t-on-click.stop="copiar" title="Copiar" aria-label="Copiar">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||
<rect x="8" y="8" width="12" height="12" rx="2.4" stroke="currentColor" stroke-width="1.8"/>
|
||||
<path d="M16 8V5.6A1.6 1.6 0 0 0 14.4 4H5.6A1.6 1.6 0 0 0 4 5.6v8.8A1.6 1.6 0 0 0 5.6 16H8" stroke="currentColor" stroke-width="1.8"/>
|
||||
</svg>
|
||||
</button>
|
||||
</t>
|
||||
</templates>
|
||||
Reference in new issue
Block a user