Browse Source

pos_remove_pos_category (#148)

* migrate to v9 and add italian translation

* short headers

* migrate JS

* [fix] be defensive: do not assume we have a product category
pull/160/merge
Simone Orsi 8 years ago
committed by Sylvain LE GAL
parent
commit
bcf5b7584b
  1. 1
      pos_remove_pos_category/README.rst
  2. 24
      pos_remove_pos_category/__init__.py
  3. 33
      pos_remove_pos_category/__manifest__.py
  4. 2
      pos_remove_pos_category/i18n/fr.po
  5. 54
      pos_remove_pos_category/i18n/it.po
  6. 3
      pos_remove_pos_category/i18n/pos_remove_pos_category.pot
  7. 2
      pos_remove_pos_category/models/__init__.py
  8. 21
      pos_remove_pos_category/models/module.py
  9. 24
      pos_remove_pos_category/models/product.py
  10. 19
      pos_remove_pos_category/point_of_sale_view.xml
  11. 48
      pos_remove_pos_category/static/src/js/pos_remove_pos_category.js
  12. 9
      pos_remove_pos_category/views/assets.xml
  13. 41
      pos_remove_pos_category/views/pos_category.xml
  14. 30
      pos_remove_pos_category/views/pos_category_view.xml
  15. 17
      pos_remove_pos_category/views/pos_view.xml

1
pos_remove_pos_category/README.rst

@ -47,6 +47,7 @@ Contributors
------------
* Sylvain Calador <sylvain.calador@akretion.com>
* Simone Orsi <simone.orsi@camptocamp.com>
Maintainer
----------

24
pos_remove_pos_category/__init__.py

@ -1,23 +1,5 @@
# -*- 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/>.
#
##############################################################################
# Copyright (C) 2015-TODAY Akretion (<http://www.akretion.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import product
from . import module
from . import models

33
pos_remove_pos_category/__manifest__.py

@ -1,28 +1,10 @@
# -*- 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/>.
#
##############################################################################
# Copyright (C) 2015-TODAY Akretion (<http://www.akretion.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'POS Remove POS Category',
'version': '8.0.0.1.0',
'author': 'Akretion, Odoo Community Association (OCA)',
'version': '9.0.0.1.0',
'author': 'Akretion, Camptocamp SA, Odoo Community Association (OCA)',
'category': 'Sales Management',
'depends': [
'point_of_sale',
@ -30,8 +12,9 @@
'demo': [],
'website': 'https://www.akretion.com',
'data': [
'point_of_sale_view.xml',
'views/pos_category.xml',
'views/assets.xml',
'views/pos_view.xml',
'views/pos_category_view.xml',
],
'installable': False,
'installable': True,
}

2
pos_remove_pos_category/i18n/fr.po

@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Project-Id-Version: Odoo Server 9.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-24 07:13+0000\n"
"PO-Revision-Date: 2015-07-24 09:20+0100\n"

54
pos_remove_pos_category/i18n/it.po

@ -0,0 +1,54 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_remove_pos_category
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-24 07:13+0000\n"
"PO-Revision-Date: 2017-01-23 13:13+0100\n"
"Last-Translator: Simone Orsi <simone.orsi@camptocamp.com>\n"
"Language-Team: \n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 1.8.9\n"
#. module: pos_remove_pos_category
#: view:product.category:pos_remove_pos_category.product_category_list_view
msgid "Available in POS"
msgstr "Disponibile nel POS"
#. module: pos_remove_pos_category
#: field:product.category,available_in_pos:0
msgid "Available in the Point of Sale"
msgstr "Disponibile nel POS"
#. module: pos_remove_pos_category
#: help:product.category,available_in_pos:0
msgid ""
"Check if you want this category to appear in Point Of Sale.\n"
"If you uncheck, children categories will becomes invisible too, whatever "
"their checkbox state."
msgstr ""
"Attiva per far apparire questa categoria nel POS.\n"
"Se disattivato, anche le sotto-categorie saranno nascoste, anche se "
"attivate singolarmente."
#. module: pos_remove_pos_category
#: model:ir.model,name:pos_remove_pos_category.model_ir_module_module
msgid "Module"
msgstr "Module"
#. module: pos_remove_pos_category
#: model:ir.model,name:pos_remove_pos_category.model_product_category
msgid "Product Category"
msgstr "Categoria Prodotto"
#. module: pos_remove_pos_category
#: model:ir.model,name:pos_remove_pos_category.model_product_template
msgid "Product Template"
msgstr "Template Prodotto"

3
pos_remove_pos_category/i18n/pos_remove_pos_category.pot

@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Project-Id-Version: Odoo Server 9.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-24 07:13+0000\n"
"PO-Revision-Date: 2015-07-24 07:13+0000\n"
@ -45,4 +45,3 @@ msgstr ""
#: model:ir.model,name:pos_remove_pos_category.model_product_template
msgid "Product Template"
msgstr ""

2
pos_remove_pos_category/models/__init__.py

@ -0,0 +1,2 @@
from . import module
from . import product

21
pos_remove_pos_category/module.py → pos_remove_pos_category/models/module.py

@ -1,23 +1,6 @@
# -*- 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/>.
#
##############################################################################
# Copyright (C) 2015-TODAY Akretion (<http://www.akretion.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models

24
pos_remove_pos_category/product.py → pos_remove_pos_category/models/product.py

@ -1,23 +1,6 @@
# -*- 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/>.
#
##############################################################################
# Copyright (C) 2015-TODAY Akretion (<http://www.akretion.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import sys
from openerp import models, fields, api, tools
@ -31,7 +14,8 @@ class ProductTemplate(models.Model):
@api.model
def create(self, vals):
vals['pos_categ_id'] = vals['categ_id']
if 'categ_id' in vals:
vals['pos_categ_id'] = vals['categ_id']
return super(ProductTemplate, self).create(vals)
@api.multi

19
pos_remove_pos_category/point_of_sale_view.xml

@ -1,19 +0,0 @@
<?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="attributes">
<attribute name="invisible">1</attribute>
</field>
</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>

48
pos_remove_pos_category/static/src/js/pos_remove_pos_category.js

@ -1,44 +1,38 @@
/******************************************************************************
* 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/>.
*
* Copyright (C) 2015-2016 Akretion (<http://www.akretion.com>).
* Copyright (C) 2017-TODAY Camptocamp SA (<http://www.camptocamp.com>).
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
******************************************************************************/
openerp.pos_remove_pos_category = function(instance, local) {
module = instance.point_of_sale;
odoo.define('pos_remove_pos_category.remove_pos_category', function (require) {
"use strict";
var initialize_original = module.PosModel.prototype.initialize;
module.PosModel = module.PosModel.extend({
var core = require('web.core');
var pos_models = require('point_of_sale.models');
var pos_screens = require('point_of_sale.screens');
var Model = require('web.DataModel');
var _t = core._t;
var _pos_super = pos_models.PosModel.prototype;
pos_models.PosModel = pos_models.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';
this.models[i].domain = [['available_in_pos', '=', true]];
}
}
return initialize_original.call(this, session, attributes);
return _pos_super.initialize.apply(this, arguments);
}
});
});
//override method js POS (widgets.js)
//change pos.category by product.category
module.ProductCategoriesWidget = module.ProductCategoriesWidget.extend({
// override method js POS (widgets.js)
// change pos.category by product.category
pos_screens.ProductCategoriesWidget.include({
get_image_url: function(category){
return window.location.origin + '/web/binary/image?model=product.category&field=image_medium&id='+category.id;
var image_url = '/web/binary/image?model=product.category&field=image_medium&id=';
return window.location.origin + image_url + category.id;
}
});
};
});

9
pos_remove_pos_category/views/assets.xml

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_backend" name="pos_remove_pos_category assets"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_remove_pos_category/static/src/js/pos_remove_pos_category.js"></script>
</xpath>
</template>
</odoo>

41
pos_remove_pos_category/views/pos_category.xml

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="assets_backend" name="pos_remove_pos_category assets"
inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_remove_pos_category/static/src/js/pos_remove_pos_category.js"></script>
</xpath>
</template>
<record id="product_category_form_view" model="ir.ui.view">
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<!-- Priority to avoid to break account and logistics fields-->
<field name="priority">20</field>
<field name="arch" type="xml">
<xpath expr="//group[@name='parent']" position="inside">
<field name="available_in_pos"/>
</xpath>
<field name="name" position="after">
<div class="oe_bottom" style="margin-top: 10px;">
<field name="image_medium"
widget="image"
class="oe_left oe_avatar"
options='{"size": [100, 100]}'/>
</div>
</field>
</field>
</record>
<record id="product_category_list_view" model="ir.ui.view">
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_list_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='complete_name']" position="after">
<field name="available_in_pos" string="Available in POS"/>
</xpath>
</field>
</record>
</data>
</openerp>

30
pos_remove_pos_category/views/pos_category_view.xml

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="product_category_form_view" model="ir.ui.view">
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<!-- Priority to avoid to break account and logistics fields-->
<field name="priority">20</field>
<field name="arch" type="xml">
<field name="type" position="after">
<field name="available_in_pos"/>
</field>
<xpath expr="//div[contains(@class,'oe_title')]" position="before">
<field name="image_medium"
widget="image"
class="oe_avatar"
options='{"size": [100, 100]}'/>
</xpath>
</field>
</record>
<record id="product_category_list_view" model="ir.ui.view">
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_list_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='complete_name']" position="after">
<field name="available_in_pos" string="Available in POS"/>
</xpath>
</field>
</record>
</odoo>

17
pos_remove_pos_category/views/pos_view.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<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="attributes">
<attribute name="invisible">1</attribute>
</field>
</field>
</record>
<record id="point_of_sale.product_pos_category_action" model="ir.actions.act_window">
<field name="res_model">product.category</field>
</record>
</odoo>
Loading…
Cancel
Save