Browse Source

[ADD] Add 'pos_product_category' module

pull/20/head
Sylvain Calador 9 years ago
parent
commit
e5551a33fb
  1. 1
      .gitignore
  2. 39
      pos_product_category/README.rst
  3. 22
      pos_product_category/__init__.py
  4. 38
      pos_product_category/__openerp__.py
  5. 22
      pos_product_category/i18n/fr.po
  6. 22
      pos_product_category/i18n/pos_product_category.pot
  7. 17
      pos_product_category/point_of_sale_view.xml
  8. 70
      pos_product_category/product.py
  9. 35
      pos_product_category/static/src/js/pos_product_category.js
  10. 10
      pos_product_category/views/pos_product_category.xml

1
.gitignore

@ -42,7 +42,6 @@ coverage.xml
# Translations
*.mo
*.pot
# Django stuff:
*.log

39
pos_product_category/README.rst

@ -0,0 +1,39 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License
POS Product Category
====================
This module was written to replace POS categories by product categories.
Installation
============
This module depends on the `point_of_sale` Odoo official module.
Configuration
=============
No configuration is needed just use product categories as standard
pos categories.
Credits
=======
Contributors
------------
* Sylvain Calador <sylvain.calador@akretion.com>
Maintainer
----------
.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.

22
pos_product_category/__init__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2015-TODAY Akretion (<http://www.akretion.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/>.
#
##############################################################################
from . import product

38
pos_product_category/__openerp__.py

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2015-TODAY Akretion (<http://www.akretion.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/>.
#
##############################################################################
{
'name': 'POS Product Category',
'version': '0.1',
'author': 'Akretion, Odoo Community Association (OCA)',
'category': 'Sales Management',
'depends': [
'point_of_sale',
],
'demo': [],
'website': 'https://www.akretion.com',
'data': [
'point_of_sale_view.xml',
'views/pos_product_category.xml',
],
'installable': True,
'auto_install': False,
}

22
pos_product_category/i18n/fr.po

@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_product_category
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-03-31 09:05+0000\n"
"PO-Revision-Date: 2015-03-31 09:05+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: pos_product_category
#: model:ir.model,name:pos_product_category.model_product_template
msgid "Product Template"
msgstr "Modèle d'article"

22
pos_product_category/i18n/pos_product_category.pot

@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_product_category
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-03-31 09:01+0000\n"
"PO-Revision-Date: 2015-03-31 09:01+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: pos_product_category
#: model:ir.model,name:pos_product_category.model_product_template
msgid "Product Template"
msgstr ""

17
pos_product_category/point_of_sale_view.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product.template.form.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="priority" eval="100"/>
<field name="arch" type="xml">
<field name="pos_categ_id" position="replace"/>
</field>
</record>
<record id="point_of_sale.product_pos_category_action" model="ir.actions.act_window">
<field name="res_model">product.category</field>
</record>
</data>
</openerp>

70
pos_product_category/product.py

@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2015-TODAY Akretion (<http://www.akretion.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/>.
#
##############################################################################
from openerp import models, fields, api
class ProductTemplate(models.Model):
_inherit = 'product.template'
pos_categ_id = fields.Many2one('product.category',
store=True, related='categ_id')
@api.model
def create(self, vals):
vals['pos_categ_id'] = vals['categ_id']
return super(ProductTemplate, self).create(vals)
@api.multi
def write(self, vals):
if 'pos_categ_id' in vals and not vals['pos_categ_id']:
del vals['pos_categ_id']
return super(ProductTemplate, self).write(vals)
_auto_end_original = models.BaseModel._auto_end
def _auto_end(self, cr, context=None):
""" Create the foreign keys recorded by _auto_init.
(pos_product_category monkey patching)
"""
context = context or {}
module = context['module']
foreign_keys = []
for t, k, r, d in self._foreign_keys:
if (t, k) == ('product_template', 'pos_categ_id'):
if module == 'pos_product_category':
cr.execute('''
ALTER TABLE product_template
DROP CONSTRAINT IF EXISTS
product_template_pos_categ_id_fkey
''')
cr.execute('''
UPDATE product_template
SET pos_categ_id = categ_id;
''')
continue
foreign_keys.append((t, k, r, d))
self._foreign_keys = foreign_keys
return _auto_end_original(self, cr, context=context)
models.BaseModel._auto_end = _auto_end

35
pos_product_category/static/src/js/pos_product_category.js

@ -0,0 +1,35 @@
/******************************************************************************
* Point Of Sale - Pricelist for POS Odoo
* Copyright (C) 2015-TODAY Akretion (http://www.akretion.com)
* @author Sylvain Calador <sylvain.calador@akretion.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/>.
*
******************************************************************************/
openerp.pos_product_category = function(instance, local) {
module = instance.point_of_sale;
var initialize_original = module.PosModel.prototype.initialize;
module.PosModel = module.PosModel.extend({
initialize: function(session, attributes) {
for (var i = 0 ; i < this.models.length; i++){
if (this.models[i].model == 'pos.category') {
this.models[i].model = 'product.category';
}
}
return initialize_original.call(this, session, attributes);
}
});
};

10
pos_product_category/views/pos_product_category.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="assets_backend" name="pos_product_category assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_product_category/static/src/js/pos_product_category.js"></script>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save