Skip to content

Commit

Permalink
Merge pull request #1880 from VoicuStefan2001/16.0
Browse files Browse the repository at this point in the history
[16.0][ADD] deltatech_pricelist_add_category
  • Loading branch information
VoicuStefan2001 authored Jan 9, 2025
2 parents 3d4ccac + 0afabdd commit 81ca407
Show file tree
Hide file tree
Showing 18 changed files with 245 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ addon | version | maintainers | summary | price
[deltatech_price_categ](deltatech_price_categ/) | 16.0.1.0.1 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Price List: Bronze Silver and Gold in product | Free
[deltatech_price_change](deltatech_price_change/) | 16.0.1.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Price Change | Free
[deltatech_price_modify_reception](deltatech_price_modify_reception/) | 16.0.1.0.2 | [![cojocariudaniel1](https://github.com/cojocariudaniel1.png?size=30px)](https://github.com/cojocariudaniel1) | Editarea pretului de lista la receptie | Free
[deltatech_pricelist_add_category](deltatech_pricelist_add_category/) | 16.0.0.0.1 | [![VoicuStefan2001](https://github.com/VoicuStefan2001.png?size=30px)](https://github.com/VoicuStefan2001) | You can add a public category to the products in price list | Free
[deltatech_print_bf](deltatech_print_bf/) | 16.0.1.0.1 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Deltatech Print Invoice to ECR | Free
[deltatech_product_catalog](deltatech_product_catalog/) | 16.0.1.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | This module helps to print the catalog of the multi products | Free
[deltatech_product_category](deltatech_product_category/) | 16.0.1.0.0 | [![dhongu](https://github.com/dhongu.png?size=30px)](https://github.com/dhongu) | Products Category | Free
Expand Down
69 changes: 69 additions & 0 deletions deltatech_pricelist_add_category/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
=======================
Price List add Category
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9da861cd00d0aeaf76615a6a6b62eed4d6114732b25bdd2029755ca774650b2e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-OPL--1-blue.png
:target: https://www.odoo.com/documentation/master/legal/licenses.html
:alt: License: OPL-1
.. |badge3| image:: https://img.shields.io/badge/github-dhongu%2Fdeltatech-lightgray.png?logo=github
:target: https://github.com/dhongu/deltatech/tree/16.0/deltatech_pricelist_add_category
:alt: dhongu/deltatech

|badge1| |badge2| |badge3|

Features:
- Gives you the possibility to add a category to a pricelist's products.
- This is done by opening the action menu on the pricelist and selecting "Open Pricelist Wizard".

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `Terrabit Issues <https://www.terrabit.ro/helpdesk>`_.
In case of trouble, please check there if your issue has already been reported.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* cojocariudaniel1
* Terrabit

Maintainers
~~~~~~~~~~~

.. |maintainer-VoicuStefan2001| image:: https://github.com/VoicuStefan2001.png?size=40px
:target: https://github.com/VoicuStefan2001
:alt: VoicuStefan2001

Current maintainer:

|maintainer-VoicuStefan2001|

This module is part of the `dhongu/deltatech <https://github.com/dhongu/deltatech/tree/16.0/deltatech_pricelist_add_category>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions deltatech_pricelist_add_category/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import wizard
18 changes: 18 additions & 0 deletions deltatech_pricelist_add_category/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "Price List add Category",
"version": "16.0.0.0.1",
"author": "cojocariudaniel1, Terrabit",
"website": "https://www.terrabit.ro",
"summary": "You can add a public category to the products in price list",
"category": "Slales",
"depends": ["sale_management", "product", "website_sale"],
"data": [
"security/ir.model.access.csv",
"data/server_action.xml",
"wizard/pricelist_wizard_view.xml",
],
"license": "OPL-1",
"images": ["static/description/main_screenshot.png"],
"development_status": "Alpha",
"maintainers": ["VoicuStefan2001"],
}
18 changes: 18 additions & 0 deletions deltatech_pricelist_add_category/data/server_action.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<odoo>
<record id="action_open_pricelist_wizard" model="ir.actions.server">
<field name="name">Open Pricelist Wizard</field>
<field name="model_id" ref="product.model_product_pricelist" />
<field name="binding_model_id" ref="product.model_product_pricelist" />
<field name="state">code</field>
<field name="code">
action = {
'type': 'ir.actions.act_window',
'name': 'Add Public Category',
'res_model': 'pricelist.wizard',
'view_mode': 'form',
'target': 'new',
'context': {'default_pricelist_id': record.id},
}
</field>
</record>
</odoo>
3 changes: 3 additions & 0 deletions deltatech_pricelist_add_category/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Features:
- Gives you the possibility to add a category to a pricelist's products.
- This is done by opening the action menu on the pricelist and selecting "Open Pricelist Wizard".
2 changes: 2 additions & 0 deletions deltatech_pricelist_add_category/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
deltatech_pricelist_add_category.access_pricelist_wizard,access_pricelist_wizard,deltatech_pricelist_add_category.model_pricelist_wizard,base.group_user,1,1,1,1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions deltatech_pricelist_add_category/static/description/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Price List add Category</title>
<link rel="stylesheet" href="https://fossies.org/linux/docutils/docutils/writers/html4css1/html4css1.css" type="text/css" />
</head>
<body>
<div class="document" id="price-list-add-category">
<h1 class="title">Price List add Category</h1>

<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9da861cd00d0aeaf76615a6a6b62eed4d6114732b25bdd2029755ca774650b2e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="https://www.odoo.com/documentation/master/legal/licenses.html"><img alt="License: OPL-1" src="https://img.shields.io/badge/licence-OPL--1-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/dhongu/deltatech/tree/16.0/deltatech_pricelist_add_category"><img alt="dhongu/deltatech" src="https://img.shields.io/badge/github-dhongu%2Fdeltatech-lightgray.png?logo=github" /></a></p>
<dl class="docutils">
<dt>Features:</dt>
<dd><ul class="first last simple">
<li>Gives you the possibility to add a category to a pricelist’s products.</li>
<li>This is done by opening the action menu on the pricelist and selecting “Open Pricelist Wizard”.</li>
</ul>
</dd>
</dl>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p class="last">This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
<a class="reference external" href="https://odoo-community.org/page/development-status">More details on development status</a></p>
</div>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-4">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://www.terrabit.ro/helpdesk">Terrabit Issues</a>.
In case of trouble, please check there if your issue has already been reported.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<ul class="simple">
<li>cojocariudaniel1</li>
<li>Terrabit</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-4">Maintainers</a></h2>
<p>Current maintainer:</p>
<p><a class="reference external image-reference" href="https://github.com/VoicuStefan2001"><img alt="VoicuStefan2001" src="https://github.com/VoicuStefan2001.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/dhongu/deltatech/tree/16.0/deltatech_pricelist_add_category">dhongu/deltatech</a> project on GitHub.</p>
<p>You are welcome to contribute.</p>
</div>
</div>
</div>
</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions deltatech_pricelist_add_category/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import pricelist_wizard
30 changes: 30 additions & 0 deletions deltatech_pricelist_add_category/wizard/pricelist_wizard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from odoo import fields, models


class PricelistWizard(models.TransientModel):
_name = "pricelist.wizard"
_description = "Pricelist Wizard"

public_category_id = fields.Many2one("product.public.category", string="Public Category", required=True)
add_to_children = fields.Boolean(string="Add to Children Categories", default=True)

def apply_category_to_products(self):
pricelist_id = self.env.context.get("default_pricelist_id")
if pricelist_id:
pricelist = self.env["product.pricelist"].browse(pricelist_id)
for line in pricelist.item_ids:
if line.applied_on == "1_product" and line.product_tmpl_id:
line.product_tmpl_id.write({"public_categ_ids": [(4, self.public_category_id.id)]})
elif line.applied_on == "2_product_category" and line.categ_id:
self._add_category_to_products(line.categ_id, self.add_to_children)
elif line.applied_on == "0_product_variant" and line.product_id:
line.product_id.write({"public_categ_ids": [(4, self.public_category_id.id)]})
elif line.applied_on == "3_global":
continue

def _add_category_to_products(self, category, add_to_children):
products = self.env["product.template"].search([("categ_id", "=", category.id)])
products.write({"public_categ_ids": [(4, self.public_category_id.id)]})
if add_to_children:
for child_category in category.child_id:
self._add_category_to_products(child_category, add_to_children)
18 changes: 18 additions & 0 deletions deltatech_pricelist_add_category/wizard/pricelist_wizard_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<odoo>
<record id="view_pricelist_wizard_form" model="ir.ui.view">
<field name="name">pricelist.wizard.form</field>
<field name="model">pricelist.wizard</field>
<field name="arch" type="xml">
<form string="Add Public Category">
<group>
<field name="public_category_id" />
<field name="add_to_children" />
</group>
<footer>
<button string="Confirm" type="object" name="apply_category_to_products" class="btn-primary" />
<button string="Cancel" class="btn-secondary" special="cancel" />
</footer>
</form>
</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/deltatech_pricelist_add_category/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon={'odoo_version_override': '16.0'},
)
6 changes: 6 additions & 0 deletions setup/deltatech_pricelist_add_categoty/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon={'odoo_version_override': '16.0'},
)

0 comments on commit 81ca407

Please sign in to comment.