Skip to content

Commit cff88bb

Browse files
committed
Merge pull request OCA#51 from LeartS/product_brand_improvements
Product brand improvements
2 parents 192990c + dc65619 commit cff88bb

File tree

5 files changed

+241
-80
lines changed

5 files changed

+241
-80
lines changed

product_brand/README.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Product Brand Manage [product_brand]
2-
===========
1+
Product Brand Manager [product_brand]
2+
=====================================
33

44
This module allows odoo users to easily manage product brands. You can
55
define brands, attach a logo and a description to them.
@@ -35,7 +35,6 @@ For further information, please visit:
3535
Known issues / Roadmap
3636
======================
3737

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

@@ -45,10 +44,11 @@ Credits
4544
Contributors
4645
------------
4746

48-
Mathieu Lemercier <[email protected]>
49-
Franck Bret <[email protected]>
50-
Seraphine Lantible <[email protected]>
51-
Gunnar Wagner <[email protected]>
47+
* Mathieu Lemercier <[email protected]>
48+
* Franck Bret <[email protected]>
49+
* Seraphine Lantible <[email protected]>
50+
* Gunnar Wagner <[email protected]>
51+
* Leonardo Donelli <[email protected]>
5252

5353
Maintainer
5454
----------

product_brand/__openerp__.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@
3232
'name': 'Product Brand Manager',
3333
'version': '0.1',
3434
'category': 'Product',
35-
'summary': ' brand',
36-
'author': "NetAndCo, Akretion,"
37-
"Prisnet Telecommunications SA,"
38-
"Odoo Community Association (OCA)",
35+
'summary': 'Add brand to products',
36+
'author': 'NetAndCo, Akretion, Prisnet Telecommunications SA'
37+
', MONK Software, Odoo Community Association (OCA)',
3938
'license': 'AGPL-3',
4039
'depends': ['product'],
4140
'data': [
4241
'product_brand_view.xml',
4342
'security/ir.model.access.csv'
44-
],
43+
],
4544
'installable': True,
4645
}

product_brand/product_brand.py

+56-40
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,71 @@
11
# -*- encoding: utf-8 -*-
22
###############################################################################
3-
# # #
4-
# product_brand for Odoo # #
5-
# Copyright (C) 2009 NetAndCo (<http://www.netandco.net>). # #
6-
# Copyright (C) 2011 Akretion Benoît Guillot <[email protected]> # #
7-
# Copyright (C) 2014 prisnet.ch Seraphine Lantible <[email protected]> # #
3+
# #
4+
# product_brand for Odoo #
5+
# Copyright (C) 2009 NetAndCo (<http://www.netandco.net>). #
6+
# Copyright (C) 2011 Akretion Benoît Guillot <[email protected]> #
7+
# Copyright (C) 2014 prisnet.ch Seraphine Lantible <[email protected]> #
8+
# Copyright (C) 2015 Leonardo Donelli #
89
# Contributors #
9-
# Mathieu Lemercier, [email protected], # #
10-
# Franck Bret, [email protected] # #
10+
# Mathieu Lemercier, [email protected] #
11+
# Franck Bret, [email protected] #
1112
# Seraphine Lantible, [email protected], http://www.prisnet.ch #
12-
# # #
13-
# This program is free software: you can redistribute it and/or modify # #
14-
# it under the terms of the GNU Affero General Public License as # #
15-
# published by the Free Software Foundation, either version 3 of the # #
16-
# License, or (at your option) any later version. # #
17-
# # #
18-
# This program is distributed in the hope that it will be useful, # #
19-
# but WITHOUT ANY WARRANTY; without even the implied warranty of # #
20-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # #
21-
# GNU Affero General Public License for more details. # #
22-
# # #
23-
# You should have received a copy of the GNU Affero General Public License # #
24-
# along with this program. If not, see <http://www.gnu.org/licenses/>. # #
25-
# # #
13+
# Leonardo Donelli, [email protected], http://www.wearemonk.com #
14+
# #
15+
# This program is free software: you can redistribute it and/or modify #
16+
# it under the terms of the GNU Affero General Public License as #
17+
# published by the Free Software Foundation, either version 3 of the #
18+
# License, or (at your option) any later version. #
19+
# #
20+
# This program is distributed in the hope that it will be useful, #
21+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
22+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
23+
# GNU Affero General Public License for more details. #
24+
# #
25+
# You should have received a copy of the GNU Affero General Public License #
26+
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
27+
# #
2628
###############################################################################
2729
###############################################################################
2830
# Product Brand is an Openobject module wich enable Brand management for #
2931
# products #
3032
###############################################################################
31-
from openerp.osv import orm, fields
33+
from openerp import models, fields, api
3234

3335

34-
class product_brand(orm.Model):
36+
class ProductBrand(models.Model):
3537
_name = 'product.brand'
36-
_columns = {
37-
'name': fields.char('Brand Name'),
38-
'description': fields.text('Description', translate=True),
39-
'partner_id': fields.many2one(
40-
'res.partner', 'partner',
41-
help='Select a partner for this brand if it exists.',
42-
ondelete='restrict'
43-
),
44-
'logo': fields.binary('Logo File'),
45-
}
4638

39+
name = fields.Char('Brand Name', required=True)
40+
description = fields.Text('Description', translate=True)
41+
partner_id = fields.Many2one(
42+
'res.partner',
43+
string='Partner',
44+
help='Select a partner for this brand if it exists',
45+
ondelete='restrict'
46+
)
47+
logo = fields.Binary('Logo File')
48+
product_ids = fields.One2many(
49+
'product.template',
50+
'product_brand_id',
51+
string='Brand Products',
52+
)
53+
products_count = fields.Integer(
54+
string='Number of products',
55+
compute='_get_products_count',
56+
)
4757

48-
class product_template(orm.Model):
58+
@api.one
59+
@api.depends('product_ids')
60+
def _get_products_count(self):
61+
self.products_count = len(self.product_ids)
62+
63+
64+
class ProductTemplate(models.Model):
4965
_inherit = 'product.template'
50-
_columns = {
51-
'product_brand_id': fields.many2one(
52-
'product.brand', 'Brand',
53-
help='Select a brand for this product.'
54-
),
55-
}
66+
67+
product_brand_id = fields.Many2one(
68+
'product.brand',
69+
string='Brand',
70+
help='Select a brand for this product'
71+
)

0 commit comments

Comments
 (0)