Skip to content

Commit

Permalink
[IMP]product_brand: Several improvements
Browse files Browse the repository at this point in the history
* add smart button, move menu to a more visible position.
* show brand in product.template kanban and tree views.
* show brand in product variant kanban and tree views.
* add product_brand kanban view.
* update module's README and manifest file.
* Search and group by brand for both product.product and product.template.
* Convert model to new APIs.
* Refactor products_count computation using product_ids one2many field.
* Add public read access to product.brand (fixes 403 error on webshop for public user).
* Make brand name required.
  • Loading branch information
LeartS authored and marielejeune committed Oct 10, 2022
1 parent 76dcd9e commit a9e6a44
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 81 deletions.
24 changes: 17 additions & 7 deletions product_brand/README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Product Brand Manage [product_brand]
===========
Product Brand Manager [product_brand]
=====================================

This module allows odoo users to easily manage product brands. You can
define brands, attach a logo and a description to them.
Expand Down Expand Up @@ -35,20 +35,30 @@ For further information, please visit:
Known issues / Roadmap
======================

* A view to list or sort products by brand
* add a field with brands assiciated to a Customer or Supplier on
the Customers/Suppliers Form View


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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
`here <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_brand%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.


Credits
=======

Contributors
------------

Mathieu Lemercier <[email protected]>
Franck Bret <[email protected]>
Seraphine Lantible <[email protected]>
Gunnar Wagner <[email protected]>
* Mathieu Lemercier <[email protected]>
* Franck Bret <[email protected]>
* Seraphine Lantible <[email protected]>
* Gunnar Wagner <[email protected]>
* Leonardo Donelli <[email protected]>

Maintainer
----------
Expand Down
11 changes: 5 additions & 6 deletions product_brand/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@
###############################################################################
{
'name': 'Product Brand Manager',
'version': '0.1',
'version': '8.0.0.1.0',
'category': 'Product',
'summary': ' brand',
'author': "NetAndCo, Akretion,"
"Prisnet Telecommunications SA,"
"Odoo Community Association (OCA)",
'summary': 'Add brand to products',
'author': 'NetAndCo, Akretion, Prisnet Telecommunications SA'
', MONK Software, Odoo Community Association (OCA)',
'license': 'AGPL-3',
'depends': ['product'],
'data': [
'product_brand_view.xml',
'security/ir.model.access.csv'
],
],
'installable': True,
}
96 changes: 56 additions & 40 deletions product_brand/product_brand.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,71 @@
# -*- encoding: utf-8 -*-
###############################################################################
# # #
# product_brand for Odoo # #
# Copyright (C) 2009 NetAndCo (<http://www.netandco.net>). # #
# Copyright (C) 2011 Akretion Benoît Guillot <[email protected]> # #
# Copyright (C) 2014 prisnet.ch Seraphine Lantible <[email protected]> # #
# #
# product_brand for Odoo #
# Copyright (C) 2009 NetAndCo (<http://www.netandco.net>). #
# Copyright (C) 2011 Akretion Benoît Guillot <[email protected]> #
# Copyright (C) 2014 prisnet.ch Seraphine Lantible <[email protected]> #
# Copyright (C) 2015 Leonardo Donelli #
# Contributors #
# Mathieu Lemercier, [email protected], # #
# Franck Bret, [email protected] # #
# Mathieu Lemercier, [email protected] #
# Franck Bret, [email protected] #
# Seraphine Lantible, [email protected], http://www.prisnet.ch #
# # #
# This program is free software: you can redistribute it and/or modify # #
# it under the terms of the GNU Affero General Public License as # #
# published by the Free Software Foundation, either version 3 of the # #
# License, or (at your option) any later version. # #
# # #
# 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 for more details. # #
# # #
# You should have received a copy of the GNU Affero General Public License # #
# along with this program. If not, see <http://www.gnu.org/licenses/>. # #
# # #
# Leonardo Donelli, [email protected], http://www.wearemonk.com #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Affero General Public License as #
# published by the Free Software Foundation, either version 3 of the #
# License, or (at your option) any later version. #
# #
# 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 for more details. #
# #
# You should have received a copy of the GNU Affero General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
###############################################################################
###############################################################################
# Product Brand is an Openobject module wich enable Brand management for #
# products #
###############################################################################
from openerp.osv import orm, fields
from openerp import models, fields, api


class product_brand(orm.Model):
class ProductBrand(models.Model):
_name = 'product.brand'
_columns = {
'name': fields.char('Brand Name'),
'description': fields.text('Description', translate=True),
'partner_id': fields.many2one(
'res.partner', 'partner',
help='Select a partner for this brand if it exists.',
ondelete='restrict'
),
'logo': fields.binary('Logo File'),
}

name = fields.Char('Brand Name', required=True)
description = fields.Text('Description', translate=True)
partner_id = fields.Many2one(
'res.partner',
string='Partner',
help='Select a partner for this brand if it exists',
ondelete='restrict'
)
logo = fields.Binary('Logo File')
product_ids = fields.One2many(
'product.template',
'product_brand_id',
string='Brand Products',
)
products_count = fields.Integer(
string='Number of products',
compute='_get_products_count',
)

class product_template(orm.Model):
@api.one
@api.depends('product_ids')
def _get_products_count(self):
self.products_count = len(self.product_ids)


class ProductTemplate(models.Model):
_inherit = 'product.template'
_columns = {
'product_brand_id': fields.many2one(
'product.brand', 'Brand',
help='Select a brand for this product.'
),
}

product_brand_id = fields.Many2one(
'product.brand',
string='Brand',
help='Select a brand for this product'
)
Loading

0 comments on commit a9e6a44

Please sign in to comment.