@ -0,0 +1,46 @@ |
|||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg |
|||
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
Mass Price Update |
|||
================= |
|||
This module allow to update the price/cost of products by percentage. |
|||
|
|||
Configuration |
|||
============= |
|||
Add the users to the new security group 'Update Product Price' to give access to the new menu. |
|||
|
|||
License |
|||
------- |
|||
General Public License, Version 3 (AGPL v3). |
|||
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
|||
|
|||
Company |
|||
------- |
|||
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
|||
|
|||
Credits |
|||
------- |
|||
* Developer: (V18) Manasa T P, Contact: odoo@cybrosys.com |
|||
|
|||
Contacts |
|||
-------- |
|||
* Mail Contact : odoo@cybrosys.com |
|||
* Website : https://cybrosys.com |
|||
|
|||
Bug Tracker |
|||
----------- |
|||
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
|||
|
|||
Maintainer |
|||
========== |
|||
.. image:: https://cybrosys.com/images/logo.png |
|||
:target: https://cybrosys.com |
|||
|
|||
This module is maintained by Cybrosys Technologies. |
|||
|
|||
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
|||
|
|||
Further information |
|||
=================== |
|||
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Manasa T P (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
from . import wizard |
@ -0,0 +1,45 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Manasa T P (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
{ |
|||
'name': 'Mass Price Update', |
|||
'version': '18.0.1.0.0', |
|||
'category': 'Warehouse', |
|||
'summary': """Update the sales price and the cost of any product by |
|||
percentage""", |
|||
'description': """This module allows to update more than one products sales |
|||
and cost price by single click""", |
|||
'author': 'Cybrosys Techno Solutions', |
|||
'company': 'Cybrosys Techno Solutions', |
|||
'maintainer': 'Cybrosys Techno Solutions', |
|||
'website': 'https://www.cybrosys.com', |
|||
'depends': ['stock'], |
|||
'data': [ |
|||
'security/mass_price_update_groups.xml', |
|||
'security/ir.model.access.csv', |
|||
'wizard/mass_price_update_views.xml' |
|||
], |
|||
'images': ['static/description/banner.png'], |
|||
'license': 'AGPL-3', |
|||
'installable': True, |
|||
'auto_install': False, |
|||
'application': False, |
|||
} |
@ -0,0 +1,7 @@ |
|||
## Module <mass_price_update> |
|||
|
|||
#### 09.10.2024 |
|||
#### Version 18.0.1.0.0 |
|||
#### ADD |
|||
|
|||
- Initial commit for Mass Price Update |
|
@ -0,0 +1,18 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Category for managing the access for product price update--> |
|||
<record id="module_category_mass_price_update" model="ir.module.category"> |
|||
<field name="name">Mass Price Update</field> |
|||
<field name="description">Helps to manage access to the mass price |
|||
update wizard |
|||
</field> |
|||
</record> |
|||
<!-- Group for Administrator--> |
|||
<record id="mass_price_update_group_admin" model="res.groups"> |
|||
<field name="name">Administrator</field> |
|||
<field name="comment">Access to the mass price update wizard menu |
|||
</field> |
|||
<field name="category_id" |
|||
ref="module_category_mass_price_update"/> |
|||
</record> |
|||
</odoo> |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 738 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 912 KiB |
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 198 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 9.9 KiB |
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Manasa T P (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
from . import change_price_line |
|||
from . import mass_price_update |
@ -0,0 +1,72 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Manasa T P (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
from odoo import api, fields, models |
|||
|
|||
|
|||
class ChangePriceLine(models.TransientModel): |
|||
"""One2many for align the products with new price""" |
|||
_name = 'change.price.line' |
|||
_rec_name = 'product_id' |
|||
_description = "Change Price Line" |
|||
|
|||
mass_price_update_id = fields.Many2one('mass.price.update', |
|||
string='Number', |
|||
help='The related field from mass' |
|||
'price update', ) |
|||
product_id = fields.Many2one( |
|||
'product.product', string='Product', required=True, |
|||
domain="[('active', '=', True)]", help='Selected products will show') |
|||
current_price = fields.Float(string='Current Price', digits='Product Price', |
|||
related='product_id.lst_price', |
|||
help='The current Sales price') |
|||
new_price = fields.Float(string='New Price', digits='Product Price', |
|||
compute='_compute_new_price_cost', |
|||
help='Computing the new price based on the ' |
|||
'percentage') |
|||
current_cost = fields.Float(string='Current Cost', digits='Product Price', |
|||
related='product_id.standard_price', |
|||
help='Current cost of the product') |
|||
new_cost = fields.Float(string='New Cost', digits='Product Price', |
|||
compute='_compute_new_price_cost', |
|||
help='Computing the new cost based on the' |
|||
'percentage') |
|||
currency_id = fields.Many2one('res.currency', |
|||
string='Currency', |
|||
related='product_id.currency_id', |
|||
help='The currency of the product') |
|||
|
|||
@api.depends('mass_price_update_id.apply_on', |
|||
'mass_price_update_id.change', |
|||
'mass_price_update_id.apply_type') |
|||
def _compute_new_price_cost(self): |
|||
"""Compute new price and new cost""" |
|||
for record in self: |
|||
if record.mass_price_update_id.apply_type == 'add': |
|||
percentage_num = 1 + record.mass_price_update_id.change |
|||
else: |
|||
percentage_num = 1 - record.mass_price_update_id.change |
|||
if record.mass_price_update_id.apply_on == 'price': |
|||
record.new_cost = False |
|||
record.new_price = record.current_price * percentage_num |
|||
else: |
|||
record.new_price = False |
|||
record.new_cost = record.current_cost * percentage_num |
@ -0,0 +1,136 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Manasa T P (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
from odoo import api, fields, models, _ |
|||
from odoo.exceptions import UserError |
|||
|
|||
|
|||
class MassPriceUpdate(models.TransientModel): |
|||
"""Change Price and Cost of Products by Percentage""" |
|||
_name = 'mass.price.update' |
|||
_description = "Mass Price Update" |
|||
|
|||
apply_to = fields.Selection([ |
|||
('all', 'All Products'), ('category', 'Selected Categories'), |
|||
('selected', 'Selected Products')], default='selected', |
|||
string='Apply To', required=True, |
|||
help='Allows to select the products based on the conditions') |
|||
apply_on = fields.Selection([ |
|||
('price', 'Price'), ('cost', 'Cost')], default='price', |
|||
string='Apply On', required=True, help='Apply on Price or Cost') |
|||
change = fields.Float(string='Change', |
|||
help='The percentage for adding or reducing to the ' |
|||
'actual price') |
|||
apply_type = fields.Selection([ |
|||
('add', 'Add'), ('reduce', 'Reduce')], default='add', |
|||
string='Apply Type', required=True, |
|||
help='Choose the applying type whether add or reduce') |
|||
product_ids = fields.Many2many( |
|||
'product.product', string='Products', default=False, |
|||
domain="[('active', '=', True)]", help='Choose the required products') |
|||
category_ids = fields.Many2many( |
|||
'product.category', string='Categories', default=False, |
|||
help='Choose the required Categories') |
|||
line_ids = fields.One2many('change.price.line', |
|||
'mass_price_update_id', |
|||
string='Lines', readonly=True, |
|||
help='The selected product with updated price') |
|||
|
|||
@api.onchange('apply_to') |
|||
def _onchange_apply_to(self): |
|||
"""When select an option from apply_to, the related records will show""" |
|||
if self.apply_to == 'all': |
|||
self.write({ |
|||
'category_ids': [(5,)], |
|||
'line_ids': [(5,)], |
|||
'product_ids': [(6, 0, self.env['product.product'].search( |
|||
[('active', '=', True)]).ids)] |
|||
}) |
|||
elif self.apply_to == 'category': |
|||
self.write({ |
|||
'line_ids': [(5,)], |
|||
'product_ids': [(6, 0, self.env['product.product'].search( |
|||
[('categ_id', 'in', self.category_ids.ids)]).ids)] |
|||
}) |
|||
else: |
|||
self.write({ |
|||
'product_ids': [(5,)], |
|||
'category_ids': [(5,)], |
|||
'line_ids': [(5,)] |
|||
}) |
|||
|
|||
@api.onchange('product_ids') |
|||
def _onchange_product_ids(self): |
|||
"""Updating the products in lines""" |
|||
if self.product_ids: |
|||
self.write({'line_ids': [(5,)]}) |
|||
lines = [] |
|||
for product in self.product_ids: |
|||
lines.append((0, 0, {'product_id': product._origin.id})) |
|||
self.write({'line_ids': lines}) |
|||
|
|||
@api.onchange('category_ids') |
|||
def _onchange_category_ids(self): |
|||
"""When select the category related product will show""" |
|||
if self.category_ids: |
|||
self.write({'line_ids': [(5,)], 'product_ids': [(5,)]}) |
|||
lines = [] |
|||
products = self.env['product.product'].sudo().search( |
|||
[('categ_id', 'in', self.category_ids.ids)]) |
|||
for product in products: |
|||
lines.append((0, 0, {'product_id': product.id})) |
|||
self.write({ |
|||
'product_ids': products.ids, |
|||
'line_ids': lines |
|||
}) |
|||
|
|||
def action_change_price(self): |
|||
"""This function is used to change the price or cost of products""" |
|||
if self.apply_to == 'category' and not self.product_ids: |
|||
raise UserError(_("Please select any category with products.")) |
|||
if self.apply_to == 'selected' and not self.product_ids: |
|||
raise UserError(_("Please select any product.")) |
|||
if not self.change: |
|||
raise UserError(_("Please enter the change in percentage.")) |
|||
if self.apply_type == 'add': |
|||
percentage_num = 1 + self.change |
|||
else: |
|||
percentage_num = 1 - self.change |
|||
if self.apply_on == 'price': |
|||
for product in self.product_ids: |
|||
product.lst_price = product.lst_price * percentage_num |
|||
else: |
|||
for product in self.product_ids: |
|||
product_template = product.product_tmpl_id |
|||
product_template.standard_price = ( |
|||
product_template.standard_price * percentage_num) |
|||
message = f"""The {'sales price' if self.apply_on == 'price' |
|||
else 'cost'} is updated.""" |
|||
return { |
|||
'type': 'ir.actions.client', |
|||
'tag': 'display_notification', |
|||
'params': { |
|||
'title': _('Success'), |
|||
'message': _(message), |
|||
'sticky': True, |
|||
'next': {'type': 'ir.actions.act_window_close'}, |
|||
} |
|||
} |
@ -0,0 +1,82 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<odoo> |
|||
<!-- Form view of the wizard--> |
|||
<record id="mass_price_update_view_form" model="ir.ui.view"> |
|||
<field name="name">mass.price.update.view.form</field> |
|||
<field name="model">mass.price.update</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Mass Price Update"> |
|||
<sheet> |
|||
<group> |
|||
<group> |
|||
<field name="apply_to" widget="radio"/> |
|||
<field name="category_ids" widget="many2many_tags" |
|||
options="{'no_create_edit': True, 'no_create': True}" |
|||
invisible="apply_to != 'category'" |
|||
required="apply_to == 'category'" |
|||
/> |
|||
<field name="product_ids" widget="many2many_tags" |
|||
options="{'no_create_edit': True, 'no_create': True}" |
|||
invisible="apply_to != 'selected'" |
|||
required="apply_to == 'selected'"/> |
|||
<field name="apply_on" widget="radio"/> |
|||
</group> |
|||
<group> |
|||
<field name="change" widget="percentage"/> |
|||
<field name="apply_type" widget="radio"/> |
|||
</group> |
|||
</group> |
|||
<notebook> |
|||
<page string="Products"> |
|||
<field name="line_ids" |
|||
invisible="product_ids == False or change == 0"> |
|||
<list string="Product List"> |
|||
<field name="product_id"/> |
|||
<field name="current_price" |
|||
widget="monetary" |
|||
options="{'currency_field': 'currency_id', 'field_digits': True}" |
|||
column_invisible="parent.apply_on == 'cost'"/> |
|||
<field name="new_price" widget="monetary" |
|||
options="{'currency_field': 'currency_id', 'field_digits': True}" |
|||
column_invisible="parent.apply_on == 'cost'"/> |
|||
<field name="current_cost" widget="monetary" |
|||
options="{'currency_field': 'currency_id', 'field_digits': True}" |
|||
column_invisible="parent.apply_on == 'price'"/> |
|||
<field name="new_cost" widget="monetary" |
|||
options="{'currency_field': 'currency_id', 'field_digits': True}" |
|||
column_invisible="parent.apply_on == 'price'"/> |
|||
<field name="currency_id"/> |
|||
</list> |
|||
</field> |
|||
</page> |
|||
</notebook> |
|||
<footer> |
|||
<button name="action_change_price" string="Change Cost" |
|||
type="object" class="oe_highlight" |
|||
invisible="apply_on == 'price'" |
|||
confirm="Are you sure you want to change the cost?"/> |
|||
<button name="action_change_price" string="Change Price" |
|||
type="object" class="oe_highlight" |
|||
invisible="apply_on == 'cost'" |
|||
confirm="Are you sure you want to change the sales price?"/> |
|||
<button string="Cancel" class="btn btn-default" |
|||
special="cancel"/> |
|||
</footer> |
|||
</sheet> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
<!-- Action for mass product update--> |
|||
<record id="mass_price_update_action" model="ir.actions.act_window"> |
|||
<field name="name">Mass Price Update</field> |
|||
<field name="res_model">mass.price.update</field> |
|||
<field name="type">ir.actions.act_window</field> |
|||
<field name="view_mode">form</field> |
|||
<field name="target">new</field> |
|||
</record> |
|||
<!-- Menu for mass product update--> |
|||
<menuitem id="menu_mass_price_update" name="Mass Price Update" |
|||
parent="stock.menu_stock_inventory_control" |
|||
action="mass_price_update_action" sequence="5" |
|||
groups="mass_price_update.mass_price_update_group_admin"/> |
|||
</odoo> |