diff --git a/pos_invoice_journal/README.rst b/pos_invoice_journal/README.rst new file mode 100644 index 00000000..e5d51df8 --- /dev/null +++ b/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 +`_. 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 `_. + +Contributors +------------ + +* Alex Comba + +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. diff --git a/pos_invoice_journal/__init__.py b/pos_invoice_journal/__init__.py new file mode 100644 index 00000000..74084f96 --- /dev/null +++ b/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 diff --git a/pos_invoice_journal/__openerp__.py b/pos_invoice_journal/__openerp__.py new file mode 100644 index 00000000..8a41b1b4 --- /dev/null +++ b/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', + ], +} diff --git a/pos_invoice_journal/models/__init__.py b/pos_invoice_journal/models/__init__.py new file mode 100644 index 00000000..4c1accb7 --- /dev/null +++ b/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 diff --git a/pos_invoice_journal/models/pos_config.py b/pos_invoice_journal/models/pos_config.py new file mode 100644 index 00000000..3632f8e4 --- /dev/null +++ b/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, + ) diff --git a/pos_invoice_journal/models/pos_order.py b/pos_invoice_journal/models/pos_order.py new file mode 100644 index 00000000..76d0263d --- /dev/null +++ b/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 diff --git a/pos_invoice_journal/static/description/icon.png b/pos_invoice_journal/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/pos_invoice_journal/static/description/icon.png differ diff --git a/pos_invoice_journal/static/description/icon.svg b/pos_invoice_journal/static/description/icon.svg new file mode 100644 index 00000000..a7a26d09 --- /dev/null +++ b/pos_invoice_journal/static/description/icon.svg @@ -0,0 +1,79 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/pos_invoice_journal/views/pos_config.xml b/pos_invoice_journal/views/pos_config.xml new file mode 100644 index 00000000..5b624cb3 --- /dev/null +++ b/pos_invoice_journal/views/pos_config.xml @@ -0,0 +1,20 @@ + + + + + + + + pos.config.form (in pos_invoice_journal) + pos.config + + + + + + + + + +