[REM] product: removed older product pricelist report
This commit is contained in:
committed by
Damien Bouvy
parent
cc20e899a2
commit
34cfd0df0d
@@ -3,4 +3,3 @@
|
||||
|
||||
from . import models
|
||||
from . import report
|
||||
from . import wizard
|
||||
|
||||
@@ -30,7 +30,6 @@ Print product labels with barcode.
|
||||
'data/product_data.xml',
|
||||
'security/product_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/product_price_list_views.xml',
|
||||
'views/res_config_settings_views.xml',
|
||||
'views/product_attribute_views.xml',
|
||||
'views/product_views.xml',
|
||||
@@ -38,7 +37,6 @@ Print product labels with barcode.
|
||||
'views/product_pricelist_views.xml',
|
||||
'views/res_partner_views.xml',
|
||||
'report/product_reports.xml',
|
||||
'report/product_pricelist_templates.xml',
|
||||
'report/product_product_templates.xml',
|
||||
'report/product_template_templates.xml',
|
||||
'report/product_packaging.xml',
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from . import product_pricelist
|
||||
@@ -1,59 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.tools import float_round
|
||||
|
||||
|
||||
class report_product_pricelist(models.AbstractModel):
|
||||
_name = 'report.product.report_pricelist'
|
||||
_description = 'Product Price List Report'
|
||||
|
||||
@api.model
|
||||
def _get_report_values(self, docids, data=None):
|
||||
data = data if data is not None else {}
|
||||
pricelist = self.env['product.pricelist'].browse(data.get('form', {}).get('price_list', False))
|
||||
products = self.env['product.product'].browse(data.get('ids', data.get('active_ids')))
|
||||
quantities = self._get_quantity(data)
|
||||
return {
|
||||
'doc_ids': data.get('ids', data.get('active_ids')),
|
||||
'doc_model': 'product.pricelist',
|
||||
'docs': products,
|
||||
'data': dict(
|
||||
data,
|
||||
pricelist=pricelist,
|
||||
quantities=quantities,
|
||||
categories_data=self._get_categories(pricelist, products, quantities)
|
||||
),
|
||||
}
|
||||
|
||||
def _get_quantity(self, data):
|
||||
form = data and data.get('form') or {}
|
||||
return sorted([form[key] for key in form if key.startswith('qty') and form[key]])
|
||||
|
||||
def _get_categories(self, pricelist, products, quantities):
|
||||
categ_data = []
|
||||
categories = self.env['product.category']
|
||||
for product in products:
|
||||
categories |= product.categ_id
|
||||
|
||||
for category in categories:
|
||||
categ_products = products.filtered(lambda product: product.categ_id == category)
|
||||
prices = {}
|
||||
for categ_product in categ_products:
|
||||
prices[categ_product.id] = dict.fromkeys(quantities, 0.0)
|
||||
for quantity in quantities:
|
||||
prices[categ_product.id][quantity] = self._get_price(pricelist, categ_product, quantity)
|
||||
categ_data.append({
|
||||
'category': category,
|
||||
'products': categ_products,
|
||||
'prices': prices,
|
||||
})
|
||||
return categ_data
|
||||
|
||||
def _get_price(self, pricelist, product, qty):
|
||||
sale_price_digits = self.env['decimal.precision'].precision_get('Product Price')
|
||||
price = pricelist.get_product_price(product, qty, False)
|
||||
if not price:
|
||||
price = product.list_price
|
||||
return float_round(price, precision_digits=sale_price_digits)
|
||||
@@ -1,69 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<template id="report_pricelist">
|
||||
<t t-call="web.html_container">
|
||||
<t t-call="web.internal_layout">
|
||||
<div class="page">
|
||||
<h2>Price List</h2>
|
||||
|
||||
<div class="row mt32 mb32">
|
||||
<div class="col-3">
|
||||
<strong>Price List Name</strong>:<br/>
|
||||
<span t-esc="data['pricelist'].name"/>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<strong>Currency</strong>:<br/>
|
||||
<span t-esc="data['pricelist'].currency_id.name"/>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<strong>Print date</strong>:<br/>
|
||||
<t t-esc="datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<strong>Description</strong>
|
||||
</th>
|
||||
<t t-foreach="data['quantities']" t-as="quantity">
|
||||
<th><strong t-esc="'%s units' % quantity"/></th>
|
||||
</t>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="data['categories_data']" t-as="categ_data">
|
||||
<tr>
|
||||
<td colspan="100">
|
||||
<strong t-esc="categ_data['category'].name"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr t-foreach="categ_data['products']" t-as="product">
|
||||
<td>
|
||||
<t t-if="product.code">
|
||||
[<span t-esc="product.code"/>]
|
||||
</t>
|
||||
<span t-esc="product.name"/>
|
||||
<span t-foreach="product.product_template_attribute_value_ids" t-as="attribute_value">
|
||||
<span t-if="attribute_value_first">-</span>
|
||||
<span t-if="not attribute_value_last" t-esc="attribute_value.name+','"/>
|
||||
<span t-else="" t-esc="attribute_value.name"/>
|
||||
</span>
|
||||
</td>
|
||||
<t t-foreach="data['quantities']" t-as="quantity">
|
||||
<td><strong t-esc="categ_data['prices'][product.id][quantity]"
|
||||
t-options="{
|
||||
'widget': 'float',
|
||||
'decimal_precision': 'Product Price'}"/>
|
||||
</td>
|
||||
</t>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
</odoo>
|
||||
@@ -161,20 +161,3 @@ class TestProductPricelist(TransactionCase):
|
||||
partner = self.res_partner_4.with_context(context)
|
||||
msg = "Wrong cost price: LCD Monitor if more than 3 Unit.should be 785 instead of %s" % ipad_mini._select_seller(partner_id=partner, quantity=3.0).price
|
||||
self.assertEqual(float_compare(ipad_mini._select_seller(partner_id=partner, quantity=3.0).price, 785, precision_digits=2), 0, msg)
|
||||
|
||||
# I print the sale prices report.
|
||||
ctx = {'active_model': 'product.product', 'date': '2011-12-30', 'active_ids': [self.computer_SC234.id, self.ipad_retina_display.id, self.custom_computer_kit.id, self.ipad_mini.id]}
|
||||
data_dict = {
|
||||
'qty1': 1,
|
||||
'qty2': 5,
|
||||
'qty3': 10,
|
||||
'qty4': 15,
|
||||
'qty5': 30,
|
||||
'price_list': self.customer_pricelist.id,
|
||||
}
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
test_reports.try_report_action(self.cr, self.uid, 'action_product_price_list', wiz_data=data_dict, context=ctx, our_module='product')
|
||||
|
||||
self.env.company.external_report_layout_id = self.env.ref('web.external_layout_standard').id
|
||||
test_reports.try_report_action(self.cr, self.uid, 'action_product_price_list', wiz_data=data_dict, context=ctx, our_module='product')
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import product_price_list
|
||||
@@ -1,34 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class product_price_list(models.TransientModel):
|
||||
_name = 'product.price_list'
|
||||
_description = 'Product Price per Unit Based on Pricelist Version'
|
||||
|
||||
price_list = fields.Many2one('product.pricelist', 'PriceList', required=True)
|
||||
qty1 = fields.Integer('Quantity-1', default=1)
|
||||
qty2 = fields.Integer('Quantity-2', default=5)
|
||||
qty3 = fields.Integer('Quantity-3', default=10)
|
||||
qty4 = fields.Integer('Quantity-4', default=0)
|
||||
qty5 = fields.Integer('Quantity-5', default=0)
|
||||
|
||||
def print_report(self):
|
||||
"""
|
||||
To get the date and print the report
|
||||
@return : return report
|
||||
"""
|
||||
if (not self.env.company.logo):
|
||||
raise UserError(_("You have to set a logo or a layout for your company."))
|
||||
elif (not self.env.company.external_report_layout_id):
|
||||
raise UserError(_("You have to set your reports's header and footer layout."))
|
||||
|
||||
datas = {'ids': self.env.context.get('active_ids', [])}
|
||||
res = self.read(['price_list', 'qty1', 'qty2', 'qty3', 'qty4', 'qty5'])
|
||||
res = res and res[0] or {}
|
||||
res['price_list'] = res['price_list'][0]
|
||||
datas['form'] = res
|
||||
return self.env.ref('product.action_report_pricelist').report_action([], data=datas)
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- Product Price List -->
|
||||
<record id="view_product_price_list" model="ir.ui.view">
|
||||
<field name="name">Price per unit</field>
|
||||
<field name="model">product.price_list</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Price List">
|
||||
<group string="Calculate Product Price per Unit Based on Pricelist Version.">
|
||||
<field name="price_list" widget="selection"/>
|
||||
<field name="qty1"/>
|
||||
<field name="qty2"/>
|
||||
<field name="qty3"/>
|
||||
<field name="qty4"/>
|
||||
<field name="qty5"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="print_report" string="Print" type="object" class="btn-primary"/>
|
||||
<button string="Cancel" class="btn-secondary" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window id="action_product_price_list"
|
||||
name="Price List"
|
||||
res_model="product.price_list"
|
||||
binding_model="product.product"
|
||||
binding_type="report"
|
||||
groups="product.group_product_pricelist"
|
||||
view_mode="form" target="new" />
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user