Browse Source

Merge pull request #109 from tafaRU/8.0-pos_invoice_journal-add

[8.0][ADD] pos_invoice_journal module
pull/114/head
Rafael Blasco 8 years ago
committed by GitHub
parent
commit
25ebc23dad
  1. 61
      pos_invoice_journal/README.rst
  2. 5
      pos_invoice_journal/__init__.py
  3. 18
      pos_invoice_journal/__openerp__.py
  4. 6
      pos_invoice_journal/models/__init__.py
  5. 29
      pos_invoice_journal/models/pos_config.py
  6. 28
      pos_invoice_journal/models/pos_order.py
  7. BIN
      pos_invoice_journal/static/description/icon.png
  8. 79
      pos_invoice_journal/static/description/icon.svg
  9. 20
      pos_invoice_journal/views/pos_config.xml

61
pos_invoice_journal/README.rst

@ -0,0 +1,61 @@
.. 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 Invoice Journal
===================
This module allows you to use a different journal for the invoices created
from the pos.
Configuration
=============
To configure this module, you need to:
#. set Invoice Journal under Point of Sales configuration
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
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.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Alex Comba <alex.comba@agilebg.com>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://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 https://odoo-community.org.

5
pos_invoice_journal/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Alex Comba - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models

18
pos_invoice_journal/__openerp__.py

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Alex Comba - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Pos Invoice Journal',
'summary': 'Use a different journal for the invoices created from the pos',
'version': '8.0.1.0.0',
'license': 'AGPL-3',
'author': 'Agile Business Group, Odoo Community Association (OCA)',
'website': 'http://www.agilebg.com',
'depends': [
'point_of_sale',
],
'data': [
'views/pos_config.xml',
],
}

6
pos_invoice_journal/models/__init__.py

@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Alex Comba - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import pos_config
from . import pos_order

29
pos_invoice_journal/models/pos_config.py

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Alex Comba - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import api, fields, models
class PosConfig(models.Model):
_inherit = 'pos.config'
@api.model
def _default_invoice_journal(self):
company_id = self._context.get(
'company_id', self.env.user.company_id.id)
domain = [
('type', '=', 'sale'),
('company_id', '=', company_id),
]
return self.env['account.journal'].search(domain, limit=1)
invoice_journal_id = fields.Many2one(
string='Invoice Journal',
help='When choosing to invoice the pos order, this is the '
'Accounting Journal used to post sales entries.',
comodel_name='account.journal',
domain=[('type', '=', 'sale')],
default=_default_invoice_journal,
)

28
pos_invoice_journal/models/pos_order.py

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Alex Comba - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import api, fields, models
class PosOrder(models.Model):
_inherit = 'pos.order'
invoice_journal_id = fields.Many2one(
related='session_id.config_id.invoice_journal_id',
string='Invoice Journal',
readonly=True,
comodel_name='account.journal',
store=True,
)
@api.multi
def action_invoice(self):
self.ensure_one()
res = super(PosOrder, self).action_invoice()
if 'res_id' in res and res['res_id']:
invoice_id = res['res_id']
self.env['account.invoice'].browse(invoice_id).write(
{'journal_id': self.invoice_journal_id.id or None})
return res

BIN
pos_invoice_journal/static/description/icon.png

After

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

79
pos_invoice_journal/static/description/icon.svg
File diff suppressed because it is too large
View File

20
pos_invoice_journal/views/pos_config.xml

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 Alex Comba - Agile Business Group
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<openerp>
<data>
<record model="ir.ui.view" id="pos_config_form_view">
<field name="name">pos.config.form (in pos_invoice_journal)</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="invoice_journal_id" widget="selection"/>
</xpath>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save