Skip to content

Commit

Permalink
[9.0][MIG] pos_remove_pos_category (#148)
Browse files Browse the repository at this point in the history
* migrate to v9 and add italian translation

* short headers

* migrate JS

* [fix] be defensive: do not assume we have a product category
  • Loading branch information
simahawk authored and legalsylvain committed Feb 28, 2017
1 parent 0990b2f commit b3ba988
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 175 deletions.
1 change: 1 addition & 0 deletions pos_remove_pos_category/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Contributors
------------

* Sylvain Calador <sylvain.calador@akretion.com>
* Simone Orsi <simone.orsi@camptocamp.com>

Maintainer
----------
Expand Down
24 changes: 3 additions & 21 deletions pos_remove_pos_category/__init__.py
Original file line number Diff line number Diff line change
@@ -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 changes: 8 additions & 25 deletions pos_remove_pos_category/__openerp__.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,20 @@
# -*- 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',
],
'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 changes: 1 addition & 1 deletion pos_remove_pos_category/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
54 changes: 54 additions & 0 deletions pos_remove_pos_category/i18n/it.po
Original file line number Diff line number Diff line change
@@ -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 changes: 1 addition & 2 deletions pos_remove_pos_category/i18n/pos_remove_pos_category.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -45,4 +45,3 @@ msgstr ""
#: model:ir.model,name:pos_remove_pos_category.model_product_template
msgid "Product Template"
msgstr ""

2 changes: 2 additions & 0 deletions pos_remove_pos_category/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import module
from . import product
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
19 changes: 0 additions & 19 deletions pos_remove_pos_category/point_of_sale_view.xml

This file was deleted.

48 changes: 21 additions & 27 deletions pos_remove_pos_category/static/src/js/pos_remove_pos_category.js
Original file line number Diff line number Diff line change
@@ -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 changes: 9 additions & 0 deletions pos_remove_pos_category/views/assets.xml
Original file line number Diff line number Diff line change
@@ -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 changes: 0 additions & 41 deletions pos_remove_pos_category/views/pos_category.xml

This file was deleted.

30 changes: 30 additions & 0 deletions pos_remove_pos_category/views/pos_category_view.xml
Original file line number Diff line number Diff line change
@@ -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>
Loading

0 comments on commit b3ba988

Please sign in to comment.