Skip to content

Commit

Permalink
Merge a95b1d6 into 800dbb3
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Nov 15, 2019
2 parents 800dbb3 + a95b1d6 commit b8dd0fd
Show file tree
Hide file tree
Showing 90 changed files with 66,234 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,3 @@
module.exports = {
"extends": "standard"
};
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -54,3 +54,6 @@ docs/_build/
# Backup files
*~
*.swp

# mobile_app_angular
!mobile_app_angular/static/src/lib/
70 changes: 70 additions & 0 deletions mobile_app_abstract/README.rst
@@ -0,0 +1,70 @@
==================
Mobile App - Tools
==================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-legalsylvain%2Fstock--logistic--barcode-lightgray.png?logo=github
:target: https://github.com/legalsylvain/stock-logistic-barcode/tree/11.0/mobile_app_abstract
:alt: legalsylvain/stock-logistic-barcode

|badge1| |badge2| |badge3|

This module is a toolkit module that provides generics tools usefull
for mobile application. It does'nt provide any end features by itself.

**Technical Information**

* Add a new abstract model ``mobile.app.mxin`` that introduces generic
functions to receive and provide json communication.

**See also**

* ``mobile_app_picking`` module (same repository)

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/legalsylvain/stock-logistic-barcode/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 <https://github.com/legalsylvain/stock-logistic-barcode/issues/new?body=module:%20mobile_app_abstract%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* GRAP

Contributors
~~~~~~~~~~~~

* Sylvain LE GAL (https://www.twitter.com/legalsylvain)

Maintainers
~~~~~~~~~~~



This module is part of the `legalsylvain/stock-logistic-barcode <https://github.com/legalsylvain/stock-logistic-barcode/tree/11.0/mobile_app_abstract>`_ project on GitHub.


You are welcome to contribute.
1 change: 1 addition & 0 deletions mobile_app_abstract/__init__.py
@@ -0,0 +1 @@
from . import models
22 changes: 22 additions & 0 deletions mobile_app_abstract/__manifest__.py
@@ -0,0 +1,22 @@
# Copyright (C) 2019-Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
'name': 'Mobile App - Tools',
'summary': 'Provides generic tools by API for Mobile Apps',
'version': '11.0.2.0.0',
'category': 'Tools',
'author': 'GRAP,Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/stock-logistics-barcode',
'license': 'AGPL-3',
'development_status': 'Beta',
'depends': [
'stock',
],
'demo': [
'demo/product_product.xml',
'demo/res_groups.xml',
],
'installable': True,
}
18 changes: 18 additions & 0 deletions mobile_app_abstract/demo/product_product.xml
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2019-Today: GRAP (http://www.grap.coop)
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->

<odoo>

<record id="product.product_product_5b_product_template" model="product.template">
<field name="barcode">9782330075989</field>
</record>

<record id="product.product_product_16_product_template" model="product.template">
<field name="barcode">9782020896320</field>
</record>

</odoo>
67 changes: 67 additions & 0 deletions mobile_app_abstract/demo/res_groups.xml
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2019-Today: GRAP (http://www.grap.coop)
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->

<odoo>

<record id="product.group_product_variant" model="res.groups">
<field name="users" eval="[
(4, ref('base.user_root')),
(4, ref('base.user_demo')),
]"/>
</record>

<record id="stock.group_tracking_owner" model="res.groups">
<field name="users" eval="[
(4, ref('base.user_root')),
(4, ref('base.user_demo')),
]"/>
</record>

<record id="stock.group_stock_multi_locations" model="res.groups">
<field name="users" eval="[
(4, ref('base.user_root')),
(4, ref('base.user_demo')),
]"/>
</record>

<record id="stock.group_stock_multi_warehouses" model="res.groups">
<field name="users" eval="[
(4, ref('base.user_root')),
(4, ref('base.user_demo')),
]"/>
</record>

<record id="stock.group_tracking_lot" model="res.groups">
<field name="users" eval="[
(4, ref('base.user_root')),
(4, ref('base.user_demo')),
]"/>
</record>

<record id="product.group_stock_packaging" model="res.groups">
<field name="users" eval="[
(4, ref('base.user_root')),
(4, ref('base.user_demo')),
]"/>
</record>

<record id="product.group_uom" model="res.groups">
<field name="users" eval="[
(4, ref('base.user_root')),
(4, ref('base.user_demo')),
]"/>
</record>

<record id="stock.group_production_lot" model="res.groups">
<field name="users" eval="[
(4, ref('base.user_root')),
(4, ref('base.user_demo')),
]"/>
</record>


</odoo>
37 changes: 37 additions & 0 deletions mobile_app_abstract/i18n/fr.po
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mobile_app_abstract
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-02-20 09:34+0000\n"
"PO-Revision-Date: 2019-02-20 09:34+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: mobile_app_abstract
#: model:ir.model.fields,field_description:mobile_app_abstract.field_mobile_app_mxin_display_name
msgid "Display Name"
msgstr "Nom à afficher"

#. module: mobile_app_abstract
#: model:ir.model.fields,field_description:mobile_app_abstract.field_mobile_app_mxin_id
msgid "ID"
msgstr "ID"

#. module: mobile_app_abstract
#: model:ir.model.fields,field_description:mobile_app_abstract.field_mobile_app_mxin___last_update
msgid "Last Modified on"
msgstr "Dernière modification le"

#. module: mobile_app_abstract
#: model:ir.model,name:mobile_app_abstract.model_mobile_app_mxin
msgid "mobile.app.mxin"
msgstr "mobile.app.mxin"

1 change: 1 addition & 0 deletions mobile_app_abstract/models/__init__.py
@@ -0,0 +1 @@
from . import mobile_app_abstract
118 changes: 118 additions & 0 deletions mobile_app_abstract/models/mobile_app_abstract.py
@@ -0,0 +1,118 @@
# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, models


class MobileAppAbstract(models.AbstractModel):
_name = 'mobile.app.mxin'

# To Overload Section
@api.model
def get_custom_fields_list(self):
"""Overload this function to define which field values should
be displayed on the mobile application, when scanning a product"""
return []

# Public API Section
@api.model
def check_group(self, group_ext_id):
return self.env.user.has_group(group_ext_id)

# Export Section
@api.model
def _export_partner(self, partner):
if not partner:
return {}
return {
'id': partner.id,
'name': partner.name,
'customer': partner.customer,
'supplier': partner.supplier,
'parent_id': self._export_partner(partner.parent_id),
}

@api.model
def _export_uom(self, uom):
if not uom:
return {}
return {
'id': uom.id,
'name': uom.name,
}

@api.model
def _export_product(self, product, custom_fields):
if not product:
return {}
# Custom product fields
custom_vals = {}
for field_name, field_display in custom_fields.items():
if field_name[-3:] == '_id':
value = getattr(product, field_name).name
elif field_name[-4:] == '_ids':
value = ", ".join(
[attr.name for attr in getattr(product, field_name)])
else:
value = getattr(product, field_name)
custom_vals[field_display] = value

return {
'id': product.id,
'name': product.name,
'display_name': product.display_name,
'barcode': product.barcode,
'custom_vals': custom_vals,
}

# Custom Section
@api.model
def _extract_param(self, params, value_path, default_value=False):
if not type(params) is dict:
return False
if '.' in value_path:
# Recursive call
value_path_split = value_path.split('.')
first_key = value_path_split[0]
return self._extract_param(
params.get(first_key),
'.'.join(value_path_split[1:]),
default_value)
else:
return params.get(value_path, default_value)

@api.model
def _get_custom_fields_dict(self):
"""Return a list of (field_name, field_display) for each custom
product fields that should be displayed during the inventory.
Don't work yet with computed fields (like display_name)"""

# Get custom fields
res = {}

custom_field_names = self.get_custom_fields_list()

# Add Custom product fields
for field_name in custom_field_names:
res[field_name] = self._get_field_display(field_name)
return res

@api.model
def _get_field_display(self, field_name):
IrTranslation = self.env['ir.translation']
# Determine model name
if field_name in self.env['product.product']._fields.keys():
model = 'product.product'
else:
model = 'product.template'
# Get translation if defined
translation_ids = IrTranslation.search([
('lang', '=', self.env.context.get('lang', False)),
('type', '=', 'field'),
('name', '=', '%s,%s' % (model, field_name))])
if translation_ids:
return translation_ids[0].value
else:
return self.env[model]._fields[field_name].string
1 change: 1 addition & 0 deletions mobile_app_abstract/readme/CONTRIBUTORS.rst
@@ -0,0 +1 @@
* Sylvain LE GAL (https://www.twitter.com/legalsylvain)
14 changes: 14 additions & 0 deletions mobile_app_abstract/readme/DESCRIPTION.rst
@@ -0,0 +1,14 @@
This module is a toolkit module that provides generics tools usefull
for mobile application. It does'nt provide any end features by itself.

It also provides demo data (barcodes on products) to make easier tests
of the mobile applications.

**Technical Information**

* Add a new abstract model ``mobile.app.mxin`` that introduces generic
functions to receive and provide json communication.

**See also**

* ``mobile_app_picking`` module (same repository)

0 comments on commit b8dd0fd

Please sign in to comment.