Las tres vistas y el buscador de Clientes pasan a ser herencias en modo primary atadas a la acción. Siguen siendo xpath sobre lo nativo, no vistas escritas de cero, pero el compromiso de no mostrar el correo aguanta por construcción y no por propagación de contexto: al registro se llega también desde una miga, un enlace o el POS, y ahí un invisible por contexto habría dejado el correo a la vista. Contactos nativo conserva su correo y su RFC, con test que lo fija. De la ficha sale el cuaderno de pestañas entero. Traía un segundo correo, un segundo bloque de dirección y una copia de las notas, y además ofrecía una pestaña de Facturación en un sistema que no factura (BRIEF §5.7). La caja de botones estadísticos se sustituye completa: media docena de módulos del core cuelgan los suyos ahí, y quitarlos uno por uno ataría la vista a qué módulos estén instalados. Quedan los dos del diseño. El widget de foto hereda del ImageField nativo, así que subir, limpiar y guardar siguen siendo los del core; lo que agrega es el menú del diseño y un diálogo de captura con la cámara TRASERA por defecto, que es el caso de uso —el mostrador retrata al cliente, no se hace una selfie—. El stream se libera al cerrar, al salir con Escape, al navegar dentro del cliente y al dejar la página; también si el diálogo se cierra antes de que la cámara termine de encender. Sin contexto seguro el navegador ni siquiera define navigator.mediaDevices, así que en las tablets no habrá diálogo de cámara hasta que producción tenga TLS. El widget no ofrece un botón que reventaría: oculta «Tomar fotografía» y deja «Subir archivo» con capture=environment, que abre la cámara nativa de Android sin exigir https. Queda anotado en despliegue.md. Las iniciales sobre durazno son un widget propio y no avatar_128: el mixin del core dibuja UNA letra sobre un color derivado del id, dentro de un SVG en base64 servido como imagen, así que ninguna hoja de estilo puede volverlo el durazno del diseño ni darle las dos letras. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
76 lines
2.9 KiB
JavaScript
76 lines
2.9 KiB
JavaScript
/** Part of Beyond. Collina Systems proprietary module. */
|
|
import { Component } from "@odoo/owl";
|
|
import { registry } from "@web/core/registry";
|
|
import { imageUrl } from "@web/core/utils/urls";
|
|
import { standardFieldProps } from "@web/views/fields/standard_field_props";
|
|
import { _t } from "@web/core/l10n/translation";
|
|
|
|
/**
|
|
* Photo, or initials on peach when there is none (Panel General design).
|
|
*
|
|
* WHY NOT avatar_128. res.partner inherits avatar.mixin, which already draws
|
|
* an SVG when the record has no photo, so this looked like reinventing the
|
|
* core. It is not, for two reasons that CSS cannot reach:
|
|
*
|
|
* · The mixin writes ONE letter (`name[0]`), and the design asks for two.
|
|
* · Its background is an HSL colour hashed from name + create_date, and the
|
|
* text is hardcoded white — inside a base64 SVG served as an <img>. The
|
|
* colour is baked into the image, so no stylesheet can turn it into the
|
|
* panel's peach.
|
|
*
|
|
* The other way out would be overriding _avatar_generate_svg on res.partner,
|
|
* which is tempting and shorter. It was not taken because avatar_128 is used
|
|
* far beyond this screen — the POS among them — and repainting every partner
|
|
* avatar in the system is a decision for whoever designs those screens, not a
|
|
* side effect of the customer list.
|
|
*/
|
|
export class BeyondAvatarInitials extends Component {
|
|
static template = "beyond_base.AvatarInitials";
|
|
static props = { ...standardFieldProps };
|
|
|
|
get valor() {
|
|
return this.props.record.data[this.props.name];
|
|
}
|
|
|
|
get nombre() {
|
|
const datos = this.props.record.data;
|
|
return (datos.name || datos.display_name || "").trim();
|
|
}
|
|
|
|
/**
|
|
* First letter of the first word plus first letter of the last one:
|
|
* "Alejandro Mcdonald" → "AM". A single word gives a single letter rather
|
|
* than two from the same word, which reads like a typo.
|
|
*/
|
|
get iniciales() {
|
|
const palabras = this.nombre.split(/\s+/).filter(Boolean);
|
|
if (!palabras.length) {
|
|
return "?";
|
|
}
|
|
const primera = palabras[0][0];
|
|
const ultima = palabras.length > 1 ? palabras[palabras.length - 1][0] : "";
|
|
return (primera + ultima).toUpperCase();
|
|
}
|
|
|
|
get url() {
|
|
return imageUrl(this.props.record.resModel, this.props.record.resId, this.props.name, {
|
|
unique: this.props.record.data.write_date,
|
|
});
|
|
}
|
|
}
|
|
|
|
export const beyondAvatarInitials = {
|
|
component: BeyondAvatarInitials,
|
|
displayName: _t("Foto o iniciales"),
|
|
supportedTypes: ["binary"],
|
|
// name feeds the initials; write_date busts the image cache after a new
|
|
// photo. Declaring them makes the views load them without each view
|
|
// having to remember.
|
|
fieldDependencies: [
|
|
{ name: "name", type: "char" },
|
|
{ name: "write_date", type: "datetime" },
|
|
],
|
|
};
|
|
|
|
registry.category("fields").add("beyond_avatar_initials", beyondAvatarInitials);
|