Browse Source

[ADD] Add pos_analytic_config module.

pull/65/head
Adrien Peiffer (ACSONE) 9 years ago
parent
commit
b5cd6eb3c2
  1. 50
      pos_analytic_config/README.rst
  2. 50
      pos_analytic_config/README.rst~
  3. 2
      pos_analytic_config/__init__.py
  4. 43
      pos_analytic_config/__openerp__.py
  5. 3
      pos_analytic_config/models/__init__.py
  6. 34
      pos_analytic_config/models/pos_config.py
  7. 34
      pos_analytic_config/models/pos_order.py
  8. BIN
      pos_analytic_config/static/description/icon.png
  9. 2
      pos_analytic_config/tests/__init__.py
  10. 96
      pos_analytic_config/tests/test_pos_analytic_config.py
  11. 15
      pos_analytic_config/views/pos_config_view.xml

50
pos_analytic_config/README.rst

@ -0,0 +1,50 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
===================
POS Analytic Config
===================
This module was written to allow to use analytic account defined on POS configuration
for invoices and accounting entries generated form POS orders.
Usage
=====
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/184/8.0
For further information, please visit:
* https://www.odoo.com/forum/help-1
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/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
`here <https://github.com/OCA/pos/issues/new?body=module:%20pos_analytic_config%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Adrien Peiffer <adrien.peiffer@acsone.eu>
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.

50
pos_analytic_config/README.rst~

@ -0,0 +1,50 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
===================
POS Analytic Config
===================
This module was written to allow to use analytic account defined on POS configuration
for invoices and accounting entries generated form POS orders.
Usage
=====
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/184/8.0
For further information, please visit:
* https://www.odoo.com/forum/help-1
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/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
`here <https://github.com/OCA/pos/issues/new?body=module:%20pos_analytic_config%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Adrien Peiffer <adrien.peiffer@acsone.eu>
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.

2
pos_analytic_config/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import models

43
pos_analytic_config/__openerp__.py

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This file is part of pos_analytic_config,
# an Odoo module.
#
# Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
#
# pos_analytic_config 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.
#
# pos_analytic_config 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 pos_analytic_config.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': "POS Analytic Config",
'summary': """Use analytic account defined on
POS configuration for POS orders""",
'author': 'ACSONE SA/NV,'
'Odoo Community Association (OCA)',
'website': "http://acsone.eu",
'category': 'Point Of Sale',
'version': '8.0.1.0.0',
'license': 'AGPL-3',
'depends': [
'point_of_sale',
],
'data': [
'views/pos_config_view.xml',
],
}

3
pos_analytic_config/models/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import pos_config
from . import pos_order

34
pos_analytic_config/models/pos_config.py

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This file is part of pos_analytic_config,
# an Odoo module.
#
# Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
#
# pos_analytic_config 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.
#
# pos_analytic_config 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 pos_analytic_config.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields
class PosConfig(models.Model):
_inherit = 'pos.config'
account_analytic_id = fields.Many2one(
comodel_name='account.analytic.account', string='Analytic Account',
domain=[('type', '!=', 'view')])

34
pos_analytic_config/models/pos_order.py

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This file is part of pos_analytic_config,
# an Odoo module.
#
# Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
#
# pos_analytic_config 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.
#
# pos_analytic_config 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 pos_analytic_config.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, api
class PosOrder(models.Model):
_inherit = 'pos.order'
@api.model
def _prepare_analytic_account(self, line):
return line.order_id.session_id.config_id.account_analytic_id.id

BIN
pos_analytic_config/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

2
pos_analytic_config/tests/__init__.py

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import test_pos_analytic_config

96
pos_analytic_config/tests/test_pos_analytic_config.py

@ -0,0 +1,96 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This file is part of pos_analytic_config,
# an Odoo module.
#
# Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
#
# pos_analytic_config 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.
#
# pos_analytic_config 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 pos_analytic_config.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.tests import common
class TestPosAnalyticConfig(common.TransactionCase):
def setUp(self):
super(TestPosAnalyticConfig, self).setUp()
self.pos_order_obj = self.env['pos.order']
self.pos_conig_obj = self.env['pos.config']
self.pos_session_obj = self.env['pos.session']
self.aml_obj = self.env['account.move.line']
self.inv_line_obj = self.env['account.invoice.line']
self.main_config = self.env.ref('point_of_sale.pos_config_main')
self.aa_01 = self.env.ref('account.analytic_root')
self.customer_01 = self.env.ref('base.res_partner_2')
self.product_01 =\
self.env.ref('point_of_sale.perrier_50cl')
self.payment_method_01 = self.env.ref('account.bank_journal')
self.aml_analytic_domain =\
[('product_id', '=', self.product_01.id),
('analytic_account_id', '=', self.aa_01.id)]
self.inv_analytic_domain =\
[('product_id', '=', self.product_01.id),
('account_analytic_id', '=', self.aa_01.id)]
def common_test(self):
self.main_config.account_analytic_id = self.aa_01
# I create and open a new session
self.session_01 = self.pos_session_obj.create(
{'config_id': self.main_config.id})
ctx = self.env.context.copy()
# context is updated in open_cb
# -> Need to call with old api to give unfrozen context
self.registry['pos.session'].open_cb(
self.cr, self.uid, [self.session_01.id], context=ctx)
# I create a new order
order_vals = {
'session_id': self.session_01.id,
'partner_id': self.customer_01.id,
'lines': [(0, 0, {'product_id': self.product_01.id,
'price_unit': 10.0,
})]
}
self.order_01 = self.pos_order_obj.create(order_vals)
# I pay the created order
payment_data = {'amount': 10,
'journal': self.payment_method_01.id}
self.pos_order_obj.add_payment(self.order_01.id, payment_data)
if self.order_01.test_paid():
self.order_01.signal_workflow('paid')
def test_order_simple_receipt(self):
self.common_test()
aml = self.aml_obj.search(self.aml_analytic_domain)
# I check that there isn't lines with the analytic account in this test
self.assertEqual(len(aml.ids), 0)
self.session_01.signal_workflow('close')
# I check that there is a journal item with the config analytic account
aml = self.aml_obj.search(self.aml_analytic_domain)
self.assertEqual(len(aml.ids), 1)
def test_order_invoice(self):
self.common_test()
lines = self.inv_line_obj.search(self.inv_analytic_domain)
self.order_01.action_invoice()
# I check that there isn't lines with the analytic account in this test
self.assertEqual(len(lines.ids), 0)
lines = self.inv_line_obj.search(self.inv_analytic_domain)
# I check that there is an invoice line
# with the config analytic account
self.assertEqual(len(lines.ids), 1)

15
pos_analytic_config/views/pos_config_view.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_pos_config_form" model="ir.ui.view">
<field name="name">pos.config.form.view (pos_analytic_config)</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.view_pos_config_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='journal_id']" position="after">
<field name="account_analytic_id" />
</xpath>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save