Browse Source

Merge PR #479 into 10.0

Signed-off-by legalsylvain
pull/532/head
OCA-git-bot 4 years ago
parent
commit
48188b4967
  1. 3
      product_brand_pos_report/__init__.py
  2. 23
      product_brand_pos_report/__manifest__.py
  3. 31
      product_brand_pos_report/i18n/es.po
  4. 26
      product_brand_pos_report/i18n/product_brand_sale_report.pot
  5. 1
      product_brand_pos_report/readme/CONTRIBUTORS.rst
  6. 2
      product_brand_pos_report/readme/DESCRIPTION.rst
  7. 2
      product_brand_pos_report/readme/ROADMAP.rst
  8. 3
      product_brand_pos_report/reports/__init__.py
  9. 80
      product_brand_pos_report/reports/pos_order_report.py
  10. 16
      product_brand_pos_report/reports/pos_order_report_view.xml
  11. BIN
      product_brand_pos_report/static/description/icon.png

3
product_brand_pos_report/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import reports

23
product_brand_pos_report/__manifest__.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Copyright 2019 PlanetaTIC - Marc Poch <mpoch@planetatic.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Product Brand POS Report',
'summary': 'Product Brand in Point of Sale Report',
'version': '10.0.1.0.0',
'description': 'Show product Brand in pos order report',
'category': 'Point Of Sale',
'author': 'PlanetaTIC, Odoo Community Association (OCA)',
'website': 'https://www.github.com/OCA/pos',
'license': 'AGPL-3',
'application': False,
'installable': True,
'depends': [
'point_of_sale',
'product_brand',
],
'data': [
'reports/pos_order_report_view.xml',
],
}

31
product_brand_pos_report/i18n/es.po

@ -0,0 +1,31 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_brand_pos_report
#
# Translators:
# PlanetaTIC - Marc Poch <mpoch@planetatic.com>, 2019
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-04-03 18:07+0000\n"
"PO-Revision-Date: 2018-04-03 18:07+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: product_brand_pos_report
#: model:ir.model.fields,field_description:product_brand_pos_report.field_report_pos_order_product_brand_id
#: model:ir.ui.view,arch_db:product_brand_pos_report.view_report_pos_order_search
msgid "Brand"
msgstr "Marca"
#. module: product_brand_pos_report
#: model:ir.model,name:product_brand_pos_report.model_report_pos_order
msgid "Point of Sale Orders Statistics"
msgstr "Punto de venta. Estadísticas pedidos"

26
product_brand_pos_report/i18n/product_brand_sale_report.pot

@ -0,0 +1,26 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_brand_sale_report
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0c\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: product_brand_sale_report
#: model:ir.model.fields,field_description:product_brand_sale_report.field_sale_report_product_brand_id
#: model:ir.ui.view,arch_db:product_brand_sale_report.view_order_product_search
msgid "Brand"
msgstr ""
#. module: product_brand_sale_report
#: model:ir.model,name:product_brand_sale_report.model_sale_report
msgid "Sales Orders Statistics"
msgstr ""

1
product_brand_pos_report/readme/CONTRIBUTORS.rst

@ -0,0 +1 @@
* Marc Poch Mallandrich <mpoch@planetatic.com>

2
product_brand_pos_report/readme/DESCRIPTION.rst

@ -0,0 +1,2 @@
Show product Brand in pos order report

2
product_brand_pos_report/readme/ROADMAP.rst

@ -0,0 +1,2 @@
The init of report.pos.order model is fully rewritten (no calling its super).
In future versions of pos module it could be great to split init method of report.pos.order model in different methods like "_select" and "_from" to avoid overwrite the full method.

3
product_brand_pos_report/reports/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import pos_order_report

80
product_brand_pos_report/reports/pos_order_report.py

@ -0,0 +1,80 @@
# -*- coding: utf-8 -*-
# Copyright 2019 PlanetaTIC - Marc Poch <mpoch@planetatic.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import api, fields, models, tools
class PosOrderReport(models.Model):
_inherit = "report.pos.order"
_auto = False
config_id = fields.Many2one('pos.config', string='Point of Sale',
readonly=True)
product_brand_id = fields.Many2one(
'product.brand',
string='Brand',
)
@api.model_cr
def init(self):
# This method is fully rewritten and does not call its super.
# In future versions of pos module it could be great to
# split init method of report.pos.order model in different
# methods like "_select" and "_from" to avoid overwrite the full method
tools.drop_view_if_exists(self._cr, 'report_pos_order')
self._cr.execute("""
CREATE OR REPLACE VIEW report_pos_order AS (
SELECT
MIN(l.id) AS id,
COUNT(*) AS nbr_lines,
s.date_order AS date,
SUM(l.qty) AS product_qty,
SUM(l.qty * l.price_unit) AS price_sub_total,
SUM(
(l.qty * l.price_unit) * (100 - l.discount) / 100) AS price_total,
SUM(
(l.qty * l.price_unit) * (l.discount / 100)) AS total_discount,
(SUM(
l.qty*l.price_unit)/SUM(l.qty * u.factor))::decimal AS average_price,
SUM(
cast(to_char(date_trunc('day',s.date_order) - date_trunc(
'day',s.create_date),'DD') AS INT)) AS delay_validation,
s.id as order_id,
s.partner_id AS partner_id,
s.state AS state,
s.user_id AS user_id,
s.location_id AS location_id,
s.company_id AS company_id,
s.sale_journal AS journal_id,
l.product_id AS product_id,
pt.categ_id AS product_categ_id,
p.product_tmpl_id,
ps.config_id,
pt.pos_categ_id,
pc.stock_location_id,
s.pricelist_id,
s.session_id,
s.invoice_id IS NOT NULL AS invoiced,
pt.product_brand_id
FROM pos_order_line AS l
LEFT JOIN pos_order s ON (s.id=l.order_id)
LEFT JOIN product_product p ON (l.product_id=p.id)
LEFT JOIN product_template pt ON (p.product_tmpl_id=pt.id)
LEFT JOIN product_uom u ON (u.id=pt.uom_id)
LEFT JOIN pos_session ps ON (s.session_id=ps.id)
LEFT JOIN pos_config pc ON (ps.config_id=pc.id)
GROUP BY
s.id, s.date_order, s.partner_id,s.state, pt.categ_id,
s.user_id, s.location_id, s.company_id, s.sale_journal,
s.pricelist_id, s.invoice_id, s.create_date, s.session_id,
l.product_id,
pt.categ_id, pt.pos_categ_id,
p.product_tmpl_id,
ps.config_id,
pc.stock_location_id,
pt.product_brand_id
HAVING
SUM(l.qty * u.factor) != 0
)
""")

16
product_brand_pos_report/reports/pos_order_report_view.xml

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2019 PlanetaTIC - Marc Poch <mpoch@planetatic.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="view_report_pos_order_search" model="ir.ui.view">
<field name="inherit_id" ref="point_of_sale.view_report_pos_order_search"/>
<field name="model">report.pos.order</field>
<field name="arch" type="xml">
<filter name="User" position="after">
<filter string="Brand" name="brand" context="{'group_by':'product_brand_id'}"/>
</filter>
</field>
</record>
</odoo>

BIN
product_brand_pos_report/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

Loading…
Cancel
Save