Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[add] pos_default_invoice_active #212

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 43 additions & 0 deletions pos_default_invoice_active/README.rst
@@ -0,0 +1,43 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License

POS default invoice active
==========================

In POS configuration you can enable invoicing.

When you do it the button "invoice" becomes available on the payment screen.

With this module you'll have a flag to enable invoicing by default
so that when you get to payment screen the invoice button is already active.


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_default_invoice_active%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.


Credits
=======

Contributors
------------

* Simone Orsi <simone.orsi@camptocamp.com>

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.
1 change: 1 addition & 0 deletions pos_default_invoice_active/__init__.py
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions pos_default_invoice_active/__manifest__.py
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2017-TODAY Camptocamp SA (<http://www.camptocamp.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'POS Default invoice activate',
'version': '10.0.1.0.0',
'author': 'Camptocamp,Odoo Community Association (OCA)',
'category': 'Sales Management',
'depends': [
'point_of_sale',
],
'demo': [],
'website': 'https://github.com/OCA/pos',
'data': [
'views/assets.xml',
'views/pos_config_view.xml',
],
'installable': True,
'license': 'AGPL-3',
}
1 change: 1 addition & 0 deletions pos_default_invoice_active/models/__init__.py
@@ -0,0 +1 @@
from . import pos_config
15 changes: 15 additions & 0 deletions pos_default_invoice_active/models/pos_config.py
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2017-TODAY Camptocamp SA (<http://www.camptocamp.com>).
# @author: Simone Orsi (https://twitter.com/simahawk)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).


from odoo import fields, models


class PosConfig(models.Model):
_inherit = 'pos.config'

iface_invoicing_active = fields.Boolean(
string='Activate invoicing by default'
)
@@ -0,0 +1,26 @@
/******************************************************************************
* Copyright (C) 2017-TODAY Camptocamp SA (<http://www.camptocamp.com>).
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
******************************************************************************/

odoo.define('pos_default_invoice_active.activate_invoicing', function (require) {
"use strict";

var pos_models = require('point_of_sale.models');
var pos_screens = require('point_of_sale.screens');

// add `iface_invoicing_active` to loaded pos config's fields
pos_models.load_fields("pos.config", "iface_invoicing_active");

pos_screens.PaymentScreenWidget.include({
show: function(){
this._super();
// activate invoicing
// TODO: any better way to check if the button is already enabled?
if (this.pos.config.iface_invoicing_active && !this.$('.js_invoice').hasClass('highlight')) {
this.$('.js_invoice').trigger('click');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better way would be to set the order as "To Invoice" when initializing it. I will try to find a way to do it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any update ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I proposed a fix in an other comment but I don't know what's the status of this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry guys, I'm not working on this (well, our related project) since a while. Feel free to carry on 😉

}
},
});

});
8 changes: 8 additions & 0 deletions pos_default_invoice_active/views/assets.xml
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_default_invoice_active/static/src/js/pos_default_invoice_active.js"></script>
</xpath>
</template>
</odoo>
13 changes: 13 additions & 0 deletions pos_default_invoice_active/views/pos_config_view.xml
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_pos_config_form" model="ir.ui.view">
<field name="name">pos.config.form.view default invoice on</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.view_pos_config_form"/>
<field name="arch" type="xml">
<field name="iface_invoicing" position="after">
<field name="iface_invoicing_active" attrs="{'invisible': [('iface_invoicing', '=', False)]}"/>
</field>
</field>
</record>
</odoo>