PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label odoo. Show all posts
Showing posts with label odoo. Show all posts

Tuesday, November 8, 2022

[FIXED] How can I add action menu in usermenu odoo15

 November 08, 2022     javascript, menu, odoo, odoo-15     No comments   

Issue

In odoo 15, how can I add new action menu in user menu? In other odoo versions (13 and 14), it was possible by inheriting from UserMenu.Actions.

In odoo 15, I tried the following code but it is not working.

Thanks for any suggestion

/** @odoo-module **/

import { registry } from "@web/core/registry";
import { preferencesItem } from "@web/webclient/user_menu/user_menu_items";

export function UserLog(env) {
    return Object.assign(
        {},
        preferencesItem(env),
        {
            type: "item",
            id: "log",
            description: env._t("UserRecent Log"),
            callback: async function () {
                const actionDescription = await env.services.orm.call("user.recent.log", "action_get");
                actionDescription.res_id = env.services.user.userId;
                env.services.action.doAction(actionDescription);
            },
            sequence: 70,
        }
    );
}

registry.category("user_menuitems").add('profile', UserLog, { force: true })

This is my model code.

class UserRecentLog(models.Model):
    _name = 'user.recent.log'
    _order = "last_visited_on desc"

    
    @api.model
    def action_get(self):
        return self.env['ir.actions.act_window']._for_xml_id('user_recent_log.action_user_activity')

This is my xml view.

    <!-- actions opening views on models -->    
    <record model="ir.actions.act_window" id="action_user_activity">
        <field name="name">User Recent Log(s)</field>
        <field name="res_model">user.recent.log</field>
        <field name="view_mode">tree,form</field>
        <field name="view_id" ref="user_activity_view_tree"/>
    </record>


Solution

You don't need to change anything, your code should work. You can check the user preferences menu item in web module (similar to your menu item).

export function preferencesItem(env) {
    return {
        type: "item",
        id: "settings",
        description: env._t("Preferences"),
        callback: async function () {
            const actionDescription = await env.services.orm.call("res.users", "action_get");
            actionDescription.res_id = env.services.user.userId;
            env.services.action.doAction(actionDescription);
        },
        sequence: 50,
    };
}

registry
    .category("user_menuitems")
    .add("profile", preferencesItem)

There is another implementation in hr module:

import { registry } from "@web/core/registry";
import { preferencesItem } from "@web/webclient/user_menu/user_menu_items";

export function hrPreferencesItem(env)  {
    return Object.assign(
        {}, 
        preferencesItem(env),
        {
            description: env._t('My Profile'),
        }
    );
}

registry.category("user_menuitems").add('profile', hrPreferencesItem, { force: true })

So you can rewrite your code above as following:

import { registry } from "@web/core/registry";
import { preferencesItem } from "@web/webclient/user_menu/user_menu_items";

export function UserLog(env) {
    return Object.assign(
        {},
        preferencesItem(env),
        {
            type: "item",
            id: "log",
            description: env._t("Log"),
            callback: async function () {
                const actionDescription = await env.services.orm.call("res.users.log", "action_user_activity");
                env.services.action.doAction(actionDescription);
            },
            sequence: 70,
        }
    );
}

registry.category("user_menuitems").add('profile', UserLog, { force: true })

Edit:

The tree view mode is ignored when executing the window action.

The _executeActWindowAction will check for the tree view type in the views registry to construct the views object and unfortunately, the tree view mode was not added to that registry.

To show the tree view, you can add [false, 'list'] to the views list and specify the view type (list) in the doAction options:

actionDescription.views.push([actionDescription.view_id[0], 'list'])
env.services.action.doAction(actionDescription, {viewType: 'list'});

Or update the views list and change tree to list:

actionDescription.views[0][1] = 'list';  

Of course , you can do the same in the action_get method:

action = self.env['ir.actions.act_window']._for_xml_id('user_recent_log.action_user_activity')
action['views'][0] = action['view_id'][0], 'list'
return action


Answered By - Kenly
Answer Checked By - Senaida (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, November 6, 2022

[FIXED] Where can i find Contacts Module in Odoo 11

 November 06, 2022     contacts, module, odoo, odoo-11     No comments   

Issue

Im trying to do a module like Contacts, but not exactly... what i want is localize the Contacts module in the Odoo 11 path and see how they do some of the thinks the show up in the module. So please can anybody tell where can i find the module in the Odoo 11 path.


Solution

You can find Contacts Directory module in your Odoo addons directory in subdirectory named contacts. The exact path in your file system depends on where you have installed Odoo. You can also explore the source in Odoo github repository at path odoo/addons/contacts, https://github.com/odoo/odoo/tree/11.0/addons/contacts.

There is no much content in this module. It is mainly just view definition that exposes base module views and forms.

I hope you can find what you are looking for from the hints from this module.



Answered By - Veikko
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, October 18, 2022

[FIXED] How to customise docker-compose containing the odoo app and postgresql with non default database name, user name and password?

 October 18, 2022     default, docker, docker-compose, odoo, postgresql     No comments   

Issue

I have an application (odoo, but my question may be for any app, I don't know) and a database with database default name, user and password. All is launched with docker-compose. With these default values, it works great (I have copy/pasted only what is relevant):

  db:
    image: postgres:14
    user: root
    environment:
      - POSTGRES_PASSWORD=odoo
      - POSTGRES_USER=odoo
      - POSTGRES_DB=postgres
  volumes:
      - ./postgresql:/var/lib/postgresql/data
  web:
    image: odoo:15
    user: root
    depends_on:
      - db
    environment:
      - HOST=db
      - USER=odoo
      - PASSWORD=odoo
  volumes:
      - ./etc:/etc/odoo
      - ./odoo-data:/var/lib/odoo

There is also a config file etc/odoo.conf which needs to be updated and I did (here the default values):

db_name = postgres
db_user = odoo
db_password = odoo

If for example I set the password to 123, the user name to my and the database name to mydb, remove the containers and suppress ./postgresql to restart clean, I get the following error from the database host:

odoo-db-1   | 2022-09-18 15:08:17.420 UTC [908] FATAL:  password authentication failed for user "my"
odoo-db-1   | 2022-09-18 15:08:17.420 UTC [908] DETAIL:  Role "my" does not exist.

Of course, I have updated both the docker-compose and odoo.conf files with my values.

What could I miss? My investigations at this point have failed.

Here is my docker-compose file:

version: '2'
services:
  db:
    image: postgres:14
    user: root
    environment:
      - POSTGRES_DB_FILE=/run/secrets/postgresql_db
      - POSTGRES_USER_FILE=/run/secrets/postgresql_user
      - POSTGRES_PASSWORD_FILE=/run/secrets/postgresql_password
    restart: always             # run as a service
    volumes:
        - ./postgresql:/var/lib/postgresql/data
    secrets:
      - postgresql_user
      - postgresql_password
      - postgresql_db

  web:
    image: odoo:15
    user: root
    depends_on:
      - db
    ports:
      - "10013:8069"
      - "20013:8072" # live chat
    tty: true
    command: --
    environment:
      - HOST=db
      - USER_FILE=/run/secrets/postgresql_user
      - PASSWORD_FILE=/run/secrets/postgresql_password
    volumes:
      - /etc/timezone:/etc/timezone:fr
      - /etc/localtime:/etc/localtime:fr
      - ./addons:/mnt/extra-addons
      - ./etc:/etc/odoo
      - ./odoo-data:/var/lib/odoo
    secrets:
      - postgresql_user
      - postgresql_password
    restart: always             # run as a service

secrets:
  postgresql_db:
    file: odoo_pg_db
  postgresql_user:
    file: odoo_pg_user
  postgresql_password:
    file: odoo_pg_pass

Here is my etc/odoo.conf:

[options]
addons_path = /mnt/extra-addons
data_dir = /etc/odoo
admin_passwd = "my_own_admin_password"
logfile = /etc/odoo/odoo-server.log
db_name = my_db
db_user = myself
db_password = "my_db_user_password"
dev_mode = reload

The entrypoint.sh:

#!/bin/bash

set -e

# set the postgres database host, port, user and password according to the environment
# and pass them as arguments to the odoo process if not present in the config file
: ${HOST:=${DB_PORT_5432_TCP_ADDR:='db'}}
: ${PORT:=${DB_PORT_5432_TCP_PORT:=5432}}
: ${USER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='odoo'}}}
: ${PASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=${POSTGRES_PASSWORD:='odoo'}}}

# install python packages
pip3 install pip --upgrade
pip3 install -r /etc/odoo/requirements.txt

# sed -i 's|raise werkzeug.exceptions.BadRequest(msg)|self.jsonrequest = {}|g' /usr/lib/python3/dist-packages/odoo/http.py

DB_ARGS=()
function check_config() {
    param="$1"
    value="$2"
    if grep -q -E "^\s*\b${param}\b\s*=" "$ODOO_RC" ; then       
        value=$(grep -E "^\s*\b${param}\b\s*=" "$ODOO_RC" |cut -d " " -f3|sed 's/["\n\r]//g')
    fi;
    DB_ARGS+=("--${param}")
    DB_ARGS+=("${value}")
}
check_config "db_host" "$HOST"
check_config "db_port" "$PORT"
check_config "db_user" "$USER"
check_config "db_password" "$PASSWORD"

case "$1" in
    -- | odoo)
        shift
        if [[ "$1" == "scaffold" ]] ; then
            exec odoo "$@"
        else
            wait-for-psql.py ${DB_ARGS[@]} --timeout=30
            exec odoo "$@" "${DB_ARGS[@]}"
        fi
        ;;
    -*)
        wait-for-psql.py ${DB_ARGS[@]} --timeout=30
        exec odoo "$@" "${DB_ARGS[@]}"
        ;;
    *)
        exec "$@"
esac

exit 1

And:

cat odoo_pg_db
my_db
cat odoo_pg_user
myself
cat odoo_pg_pass
my_db_user_password

And my project folder tree:

.
├── addons
│   └── readme.md
├── docker-compose.yml
├── entrypoint.sh
├── etc
│   ├── addons
│   │   └── 15.0
│   ├── odoo.conf
│   ├── odoo.conf.meld
│   ├── odoo-server.log
│   ├── requirements.txt
│   └── sessions
├── odoo-data
├── odoo_pg_db
├── odoo_pg_pass
├── odoo_pg_user
├── postgresql [error opening dir]
├── README.md
├── run.sh
└── screenshots
    ├── odoo-13-apps-screenshot.png
    ├── odoo-13-sales-form.png
    ├── odoo-13-sales-screen.png
    └── odoo-13-welcome-screenshot.png

The odoo:15 dockerfile does not include hard written database name nor user regarding the database, only an app user set to odoo, but this is for the web app. It makes use of a config file with the default database name user and password like depicted above, but I provide the modified one with my values. The docker files makes use of ENV to refer to it: ENV ODOO_RC /etc/odoo/odoo.conf. Then it runs an entrypoint containing:

DB_ARGS=()
function check_config() {
    param="$1"
    value="$2"
    if grep -q -E "^\s*\b${param}\b\s*=" "$ODOO_RC" ; then       
        value=$(grep -E "^\s*\b${param}\b\s*=" "$ODOO_RC" |cut -d " " -f3|sed 's/["\n\r]//g')
    fi;
    DB_ARGS+=("--${param}")
    DB_ARGS+=("${value}")
}
check_config "db_host" "$HOST"
check_config "db_port" "$PORT"
check_config "db_user" "$USER"
check_config "db_password" "$PASSWORD"

With these check_config, it gets my values from the config file.

The postgres:14 dockerfile contains only the superuser name postgres set with a useradd.

Note: of course, there is more to be done after this like replace root user, use Docker secrets, but that's another topic.


Solution

The postgresql folder contents were not suppressed with sudo rm -fr postgresql/* while the containers were deleted, since created with the odoo user. I have to do sudo chmod -R 777 postgresql before.

Now I can see in the docker console that the environment variables are correctly set. Other problems now, but this one is solved.



Answered By - lalebarde
Answer Checked By - David Marino (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, August 31, 2022

[FIXED] How to keep translations separated where the same word is used in English but a different one in other languages?

 August 31, 2022     multilingual, odoo, po, poedit, translation     No comments   

Issue

Imagine I have a report, a letter actually, which I need to translate to several languages. I have created a greeting field in the form which is filled programatically by an onchange event method.

if self.partner_id.gender == 'female':
    self.letter_greeting = _('Dear %s %s,') % (         # the translation should be "Estimada"
        self.repr_recipient_id.title.shorcut, surname
    )
elif self.partner_id.gender == 'male':
    self.letter_greeting = _('Dear %s %s,') % (         # translation "Estimado"
        self.repr_recipient_id.title.shorcut, surname
    )
else:
    self.letter_greeting = _('Dear %s %s,') % (         # translation: "Estimado/a"
        self.partner_id.title.shorcut, surname
    )

In that case the word Dear should be translated to different Spanish translations depending on which option is used, this is because we use different termination depending on the gender. Exporting the po file I found that all the options are altogether, that make sense because almost all the cases the translations will be the same, but not in this case:

#. module: custom_module
#: code:addons/custom_module/models/sale_order.py:334
#: code:addons/custom_module/models/sale_order.py:338
#: code:addons/custom_module/models/sale_order.py:342
#, python-format
msgid "Dear %s %s,"
msgstr "Dear %s %s,"

Solutions I can apply directly

  • Put all the terms in different entries to avoid the same translation manually every time I need to update the po file. This can be cumbersome if you have many different words with that problem. If I do it and I open the file with poedit, this error appears: duplicate message definition

    enter image description here

  • Put all the possible combinations with slashes, this is done y some other parts of Odoo. For both gender would be:

#. module: stock
#: model:res.company,msg:stock.res_company
msgid "Dear"
msgstr "Estimado/a"

This is just an example. I can think of many words that look the same in English, but they use different spelling or meanings in other languages depending on the context.

Possible best solutions

  • I don't know if Odoo know anything aboutu the context of a word to know if it was already translated or not. Adding a context manually could solve the problem, at least for words with different meanings.

  • The nicest solution would be to have a parameter to the translation module to make sure that the word is exported as an isolated entry for that especific translation.

Do you think that I am giving to it too much importance haha? Do you know if there is any better solution? Why is poedit not taking into account that problem at all?


Solution

I propose an extension of models res.partner.title and res.partner.

res.partner.title should get a translateable field for saving salutation prefixes like 'Dear' or 'Sehr geehrter' (German). Maybe it's worth to get something about genders, too, but i won't get into detail here about that. You probably want to show the configuring user an example like "Dear Mr. Name" or something like that. A computed field should work.

On res.partner you should just implement either a computed field or just a method to get a full salutation for a partner record.



Answered By - CZoellner
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, August 24, 2022

[FIXED] How to customize Web-editor Top-menu in Odoo v13?

 August 24, 2022     javascript, module, odoo, odoo-13, summernote     No comments   

Issue

I have created a new module ("webeditor_custom") to customize Odoo v13 Web editor Top menu to add custom font-sizes in the existing menu items.

enter image description here

The files in my module "webeditor_custom" are :

  1. templates/assets.xml file :
<?xml version="1.0" encoding="utf-8" ?>

<odoo>

<template id="summernote_cust" name="My summernote assets" inherit_id="web_editor.summernote">

<xpath expr="//script[last()]" position="after">

<script type="text/javascript" src="/webeditor_custom/static/src/js/summernote_cust.js"></script>

</xpath>

</template>

</odoo>
  1. In /static/src/js/ directory, i have my summernote_cust.js file :
odoo.define('web_editor.summernote_cust', function (require) {

'use strict';

var core = require('web.core');

var editor = require('web_editor.summernote');

require('summernote/summernote'); // wait that summernote is loaded

var _t = core._t;

var options = $.summernote.options;

options.fontSizes = [_t('Default'), 8, 9, 10, 11, 12, 13, 14, 16, 18, 21, 24, 28, 32, 36, 42, 49, 56, 63];

return $.summernote;

});
  1. my manifest.py file:
{
    "name": "Web editor custom",
    "summary": "Add font-sizes to the top-menu of the web editor",
    "version": "13.0.2.0.1",
    "installable": True,
    "depends": ["web_editor"],
    "data": ["templates/assets.xml"],
}

After installing my module, i get this error (popup) displayed on the first load of my homepage:

"Error: Service web_editor.summernote_cust already defined"

Thank you if you have a way to deal with it (summernote on odoo v13) or a workaround !


Solution

Try to add your script to the assets_wysiwyg bundle, so it will be added after all the summernote scripts

Example:

<template id="summernote_cust" name="My summernote assets" inherit_id="web_editor.assets_wysiwyg">
    <xpath expr="//script[last()]" position="after">
        <script type="text/javascript" src="/webeditor_custom/static/src/js/summernote_cust.js"></script>
    </xpath>
</template>


Answered By - Kenly
Answer Checked By - Robin (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Monday, July 11, 2022

[FIXED] How to set 'email' in author_id inherit mail.thread on Odoo

 July 11, 2022     message, odoo, python     No comments   

Issue

I inherit mail.thread on Odoo12

_inherit = ['mail.thread', 'mail.activity.mixin']

and publish a message:

msg = 'message test.'
self.message_post(body=msg, email_from='Otro <otro@otro.com>', subtype='mail.mt_comment',)

image

These messages are added with the administrator user. How can I place the mail of the external user who sends the message in the field author_id?


Solution

Try out self.message_post(body=msg, email_from='Otro <otro@otro.com>', subtype='mail.mt_comment', author_id=False)

author_id=False will tell Odoo to use the email_from as author.

I've found that "trick" here:

    author_id = kwargs.get('author_id')
    if author_id is None:  # keep False values
        author_id = self.env['mail.message']._get_default_author().id

The semi-valuable comment # keep False values solved the big secret ;-)

With None the user of the current environment would be used.



Answered By - CZoellner
Answer Checked By - Marilyn (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, July 10, 2022

[FIXED] How to popup success message in odoo?

 July 10, 2022     message, odoo, popup, python     No comments   

Issue

I am sending invitation by clicking button after clicking button and successfully sending invitation there is pop up message of successfully invitation send. But the problem is that the main heading of pop up message is Odoo Server Error. That is because I am using

raise osv.except_osv("Success", "Invitation is successfully sent")

Is there any alternative to make it better.


Solution

When I need something like this I have a dummy wizard with message field, and have a simple form view that show the value of that field.

When ever I want to show a message after clicking on a button I do this:

     @api.multi
     def action_of_button(self):
        # do what ever login like in your case send an invitation
        ...
        ...
        # don't forget to add translation support to your message _()
        message_id = self.env['message.wizard'].create({'message': _("Invitation is successfully sent")})
        return {
            'name': _('Successfull'),
            'type': 'ir.actions.act_window',
            'view_mode': 'form',
            'res_model': 'message.wizard',
            # pass the id
            'res_id': message_id.id,
            'target': 'new'
        }

The form view of message wizard is as simple as this:

<record id="message_wizard_form" model="ir.ui.view">
    <field name="name">message.wizard.form</field>
    <field name="model">message.wizard</field>
    <field name="arch" type="xml">
        <form >
            <p class="text-center">
                <field name="message"/>
            </p>
        <footer>
            <button name="action_ok" string="Ok" type="object" default_focus="1" class="oe_highlight"/> 
        </footer>
        <form>
    </field>
</record>

Wizard is just simple is this:

class MessageWizard(model.TransientModel):
    _name = 'message.wizard'

    message = fields.Text('Message', required=True)

    @api.multi
    def action_ok(self):
        """ close wizard"""
        return {'type': 'ir.actions.act_window_close'}

Note: Never use exceptions to show Info message because everything run inside a big transaction when you click on button and if there is any exception raised a Odoo will do rollback in the database, and you will lose your data if you don't commit your job first manually before that, witch is not recommended too in Odoo



Answered By - Charif DZ
Answer Checked By - Marilyn (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Saturday, June 25, 2022

[FIXED] How to hide odoo server information with httpd as reverse proxy

 June 25, 2022     apache, odoo, odoo-13, reverse-proxy     No comments   

Issue

I installed odoo on centos 8 and use httpd as a reverse proxy. Like other Apache hardening, I use ServerTokens Proddan ServerSignature Off to hide server information.

but when I try wget the results still show server information

Spider mode enabled. Check if remote file exists.
--2020-03-12 11:57:14--  http://my.domain/
Resolving my.domain (my.domain)... 169.0.0.1
Connecting to my.domain (my.domain)|169.0.0.1|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 301 Moved Permanently
  Content-length: 0
  Location: https://my.domain/
Location: https://my.domain/ [following]
Spider mode enabled. Check if remote file exists.
--2020-03-12 11:57:14--  https://my.domain/
Connecting to my.domain (my.domain)|169.0.0.1|:443... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 200 OK
  Date: Thu, 12 Mar 2020 04:56:55 GMT
  Server: Werkzeug/0.14.1 Python/3.7.5
  Content-Type: text/html; charset=utf-8
  Content-Length: 10589
  Set-Cookie: frontend_lang=en_US; Path=/
  Set-Cookie: session_id=s8487a5ec76bd455f42680c38195b5f7f0285d563; Expires=Wed, 10-Jun-2020 04:56:55 GMT; Max-Age=7776000; HttpOnly; Path=/
  Vary: User-Agent
Length: 10589 (10K) [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.

Solution

well it can use mod_header and mod_rewrite, then add

add Header set Server "value that you want" to your apache virtual host



Answered By - Vikri Usman Rizky
Answer Checked By - Senaida (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, May 10, 2022

[FIXED] How do I create a table showing a combination of product variants in qweb report?

 May 10, 2022     odoo, product, python, qweb, report     No comments   

Issue

I would like to display my products in tables depending on what variants they have. If a product has two attributes, I would like it displayed in a table with the values (of the attributes with the least values) as the column headers, and the other attribute values headers as the row headers. If a product has one or no attributes, then the attribute values should be the row headers. If a product has more than two attributes, the remainder attributes should form a separate table adjacent to the original table.

I managed to get the row headers working, but couldn't get the column headers and the prices of each product variant working. Here is my code:

<?xml version="1.0"?>

<t t-name="product.report_menu">
  <t t-call="web.html_container">
    <t t-call="web.internal_layout">

      <div class="page" style="height: 28cm; width: 21cm; font-family: Patrick Hand;">

        <table style="width: 100%; padding-top: 30px">
          <tbody>
            <tr>

              <td valign="top" style="width: 75%; border: solid 2px orange;padding-left: 20px;padding-right: 20px;">
                <div style="min-height: 29.5cm;">

                  <!-- setting default groupings to nil-->
                  <t t-set="product_category" t-value="[]" />
                  <t t-set="attribute_category" t-value="[]" />
                  <t t-set="name_category" t-value="[]" />
                  <t t-set="attribute_value_name_category" t-value="[]" />
                  <t t-set="price" t-value="[]" />
                  <t t-set="pricf" t-value="[]" />


                  <!-- setting default groupings to nil-->
                  <t t-foreach="docs" t-as="mpl">

                    <!-- setting grouping to the value of the product-->
                    <t t-set="product_category" t-value="product_category+[mpl.categ_id]" />
                  </t>


                  <!-- lines associated for grouping individual products based on category, i.e Cookies and all its variants  -->
                  <t t-foreach="set(product_category)" t-as="category">

                    <!-- product category name -->
                    <strong>
                                            <h3 t-esc="category.name" /> </strong>

                    <!-- setting grouping to the value of the product-->
                    <t t-foreach="docs" t-as="mpl">
                      <t t-set="name_category" t-value="name_category+[mpl.name]" />

                      <t t-set="price" t-value="price+[mpl.lst_price]" />


                      <t t-foreach="mpl.attribute_value_ids" t-as="attrib_value">
                        <t t-set="pricf" t-value="pricf+[mpl.lst_price]" />
                        <t t-set="attribute_category" t-value="attribute_category+[attrib_value.attribute_id]" />
                        <t t-set="attribute_value_name_category" t-value="attribute_value_name_category+[attrib_value]" />
                      </t>
                      <!-- <t t-foreach="mpl.attribute_value_ids" t-as="attrib_value"> -->

                    </t>

                    <t t-foreach="set(name_category)" t-as="namecate">
                      <strong>
                                                <h4 t-esc="namecate" /></strong>
                      <!-- if the products have attributes such as Size, create a size layout table -->



                      <table style="width: 50%; margin-bottom: 15px;">
                        <thead>
                          <th>Whatever...</th>
                          <th>att 1</th>
                          <th>att 2</th>
                          <th>att 4</th>
                        </thead>

                        <tbody>

                          <!-- setting grouping to the value of the product-->

                          <t t-foreach="set(attribute_category)" t-as="attric">
                            <t t-set="attribute_category" t-value="[]" />
                            <t t-if="not attric.name == 'Size'">
                              <strong>
                                    <h5 style="color: gray;" t-esc="'Comes in %ss of:' % (attric.name)" />
                                </strong>

                              <t t-foreach="set(attribute_value_name_category)" t-as="avnc">
                                <t t-if="avnc.attribute_id.name == attric.name">

                                  <t t-set="attribute_category" t-value="[]" />

                                  <tr>
                                    <td>
                                      <p t-esc="avnc.name" />
                                    </td>

                                    <t t-foreach="set(price)" t-as="pricee">
                                      <t t-if="not pricee == 0">

                                        <td>
                                          <span t-esc="'%s' % (pricee)" />
                                        </td>

                                      </t>
                                    </t>

                                  </tr>
                                </t>
                              </t>
                            </t>
                          </t>
                        </tbody>

                      </table>
                    </t>
                  </t>
                </div>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    </t>
  </t>

</t>

This is a list of the products and their attributes: products and their attribute

And this is the report generated: what report I am currently getting what report I am currently getting

This is my target:what I am trying to do

what I am trying to do

Could I please get some help, I am not sure how to proceed.

Thank you


Solution

I think that you better use a custom report parser to create groups of information to provide it to the report template in order to just iterate a custom data structure to print the previously prepared data into the needed tables and report output.

This seems to be a very complex report to be build against so many relation fields that will lead to so many iterations and boilerplate code at the qweb level.



Answered By - Axel Mendoza
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home
View mobile version

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing