I wanted a way to add a custom field to odoo pos receipt and followed a cybrosys tut on another post of this forum.
I did everything cybrossys did show but I always end up with a blank white screen and odoo service stucking.
My model consist of:
show_credit.py:
from odoo import api, fields, models, _
class ShowCredit(models.Model):
_inherit = "product.product"
credits = fields.Many2one("res.partner")
related_field = fields.Monetary(related="credits.credit")
add2pos.js:
odoo.define('show_credit.Credit', finction(require) {
'use strict';
var models = require('point_of_sale.models');
var _super_products = models\.PosModel\.prototype;
\ \ \ \
\ \ \ \ models\.PosModel\ =\ models\.PosModel\.extend\(\{
\ \ \ \ \ \ \ \ initialize:\ function\(session,\ attributes\)\{
\ \ \ \ \ \ \ \ \ \ \ var\ self\ =\ this;
\ \ \ \ \ \ \ \ \ \ \ \ models\.load_fields\('product\.product',\ \['new_field'\]\);
\ \ \ \ \ \ \ \ \ \ \ \ _super_product\.initialize\.apply\(this,\ arguments\);
\ \ \ \ \ \ \ \ \}
\ \ \ \ \}\);
\}\);
pass2receipt\.js:
odoo\.define\('show_credit\.receipt',\ function\(require\)\{
\ \ \ \ "use\ strict";
\ \ \ \ var\ models\ =\ require\('product\.product',\ 'product_grade_id'\);
\ \ \ \ var\ _super_orderline\ =\ models\.Orderline\.prototype;
\ \ \ \ models\.Orderline\ =\ models\.Orderline\.extend\(\{
\ \ \ \ \ \ \ \ export_for_printing:\ function\(\)\{
\ \ \ \ \ \ \ \ \ \ \ \ var\ line\ =\ _super_orderline\.export_for_printing\.apply\(this,\ arguments\);
\ \ \ \ \ \ \ \ \ \ \ \ line\.related_field\ =\ this\.get_product\(\)\.related_field;
\ \ \ \ \ \ \ \ \ \ \ \ return\ line;
\ \ \ \ \ \ \ \ \}
\ \ \ \ \}\);
\}\);
template\.xml:
\ \ \ \
\ \ \ \
\ \ \ \ \ \ \ \
\ \ \ \
\ \ \ \
and\ manifest\ file:
\{
\ \ \ \ 'name':\ "Show\ credit",
\ \ \ \ 'author':\ '',
\ \ \ \ 'category':\ 'Point\ of\ Sale',
\ \ \ \ 'summary':\ "Show\ credit\ on\ the\ receipt\.",
\ \ \ \ 'website':\ '',
\ \ \ \ 'description':\ """
Being\ able\ to\ show\ the\ credit\ the\ client\ have\ to\ pay\ to\ the\ company\.
\ \ \ \ """,
\ \ \ \ 'version':\ '1\.0',
\ \ \ \ 'depends':\ \['point_of_sale'\],
\ \ \ \ 'assets':\ \{
\ \ \ \ \ \ \ \ \ 'web\.assets_backend':\ \[
\ \ \ \ \ \ \ \ \ \ \ \ \ 'show_credit/static/src/js/add2pos\.js',
\ \ \ \ \ \ \ \ \ \ \ \ \ 'show_credit/static/src/js/pass2receipt\.js',
\ \ \ \ \ \ \ \ \ \ \ \ \ \#'show_credit/static/src/xml/template\.xml',
\ \ \ \ \ \ \ \ \ \],
\ \ \ \ \ \ \ \ \ \#'web\.assets_qweb':\ \[
\ \ \ \ \ \ \ \ \ \#\ \ \ \ '/show_credit/static/src/xml/template\.xml',
\ \ \ \ \ \ \ \ \ \#\],
\ \ \ \ \},
\ \ \ \ 'data':\ \[
\ \ \ \ \ \ \ \ \ \#\ 'views/templates\.xml',
\ \ \ \ \ \ \ \ \ \#\ 'static/src/xml/template\.xml'
\ \ \ \ \],
\ \ \ \ 'qweb':\ \[
\ \ \ \ \ \ \ \ 'static/src/xml/template\.xml'
\ \ \ \ \],
\ \ \ \ 'installable':\ True,
\ \ \ \ 'application':\ True,
\ \ \ \ 'auto_install':\ False,
\}
I\ don't\ know\ what\ is\ causing\ the\ error\ but\ I\ think\ most\ probably\ this\ line\ here
\ \ \ \ 'qweb':\ \[
\ \ \ \ \ \ \ \ 'static/src/xml/template\.xml'
\ \ \ \ \],
Logs: