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

[15.0] pos_debt_notebook #1479

Open
wants to merge 8 commits into
base: 15.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions pos_debt_notebook/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.. image:: https://itpp.dev/images/infinity-readme.png
:alt: Tested and maintained by IT Projects Labs
:target: https://itpp.dev

======================
POS: Prepaid credits
======================

The module allows to make sale on credit.

Debt (Credit) value is changed whenever:

* Product marked as "Credit Product" is sold via POS or via Invoices. Invoices created via website_sale (eCommerce) module are supported too.
* POS payment is made via journal marked as "Debt journal"
* "Manual Credit Updates" is added

Other features:

* each user has Debt Limit field. By default is 0, i.e. user has to pay in advance and cannot have negative credits amount.
* Working with employees of company. You can get a sum of Credits of all employess of any company. You can make invoices per each employee at once to updates their Credits.

Installation \ Deinstallation
=============================

* Debt data are still available after the module will be re-installed.
* When new (first after install) POS session is opened, a debt payment method would added in a POS config.
* If the module was install and uninstall immediately (without created POS sessions) then it keeps no data.
* If a user deleted debt journal from POS config manually then after the module is upgraded
POS config would not be changed.
* Multicompany mode is supported

Roadmap
=======

* TODO. Field ``journal_id`` in ``pos.credit.update`` model should be replaced with ``pos_payment_method_id = fields.Many2on('pos.payment.method')``

* TODO. New option for **Zero transactions** feature: allow to create extra order line with negative amount instead of applying discounts.

* It creates extra record in accounting system (pos.order.line). It can be used as a backup for *Manual Updates*
* It works with following problem case:

In case of purchasing products with taxes not included in the price, such journals cannot be used along with normal payments

* TODO. Improvements on heavy usage (Many POSes, Many Partners)

* Num of users with cached Debt History must be limited
* Limit issue in ``reload_debts`` (check FIXME note there)
* Many POSes do the same requests on getting updates from longpolling. Solution:

* Customizable timeout in ``on_debt_updates`` method in ``pos_debt_notebook_sync`` module.
* ``reload_debts`` called with ``"postpone": false`` must ignore existing timer

Questions?
==========

To get an assistance on this module contact us by email :arrow_right: help@itpp.dev

Contributors
============
* `Ivan Yelizariev <https://it-projects.info/team/yelizariev>`__
* `Stanislav Krotov <https://it-projects.info/team/ufaks>`__
* `Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>`__
* `Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>`__

Further information
===================

Odoo Apps Store: https://apps.odoo.com/apps/modules/14.0/pos_debt_notebook/


Tested on `Odoo 14.0 <https://github.com/odoo/odoo/commit/c28a32daa56193d97f0d91dac1fe560603b8837b>`_
25 changes: 25 additions & 0 deletions pos_debt_notebook/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# License MIT (https://opensource.org/licenses/MIT).
from . import models
from . import report
from . import wizard

from odoo import SUPERUSER_ID
from odoo import api
from odoo.tools.translate import _
from odoo.exceptions import UserError


def pre_uninstall(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
if env["pos.session"].search([("state", "=", "opened")]):
raise UserError(
_("You have open session of Point of Sale. Please close them first.")
)

debt_journals = env["account.journal"].search([("debt", "=", True)])
value = []
for journal in debt_journals:
value.append((3, journal.id))

for config in env["pos.config"].search([]):
config.write({"payment_method_ids": value})
45 changes: 45 additions & 0 deletions pos_debt_notebook/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2014-2019 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2015 Bassirou Ndaw <https://github.com/bassn>
# Copyright 2015 Alexis de Lattre <https://github.com/alexis-via>
# Copyright 2016-2017 Stanislav Krotov <https://it-projects.info/team/ufaks>
# Copyright 2017 Ilmir Karamov <https://it-projects.info/team/ilmir-k>
# Copyright 2017 Artyom Losev
# Copyright 2017 Lilia Salihova
# Copyright 2017-2018 Gabbasov Dinar <https://it-projects.info/team/GabbasovDinar>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# Copyright 2021 Denis Mudarisov <https://github.com/trojikman>
# License MIT (https://opensource.org/licenses/MIT).
{
"name": "POS: Prepaid credits",
"summary": "Comfortable sales for your regular customers. Debt payment method for POS",
"category": "Point Of Sale",
"images": ["images/debt_notebook.png"],
"version": "15.0.5.3.4",
"author": "IT-Projects LLC, Ivan Yelizariev",
"support": "apps@itpp.dev",
"website": "https://github.com/itpp-labs/pos-addons/",
"license": "Other OSI approved licence", # MIT
"external_dependencies": {"python": [], "bin": []},
"depends": ["point_of_sale"],
"data": [
"security/pos_debt_notebook_security.xml",
"data/product.xml",
"views/pos_debt_report_view.xml",
"views.xml",
"views/pos_credit_update.xml",
"wizard/pos_credit_invoices_views.xml",
"wizard/pos_credit_company_invoices_views.xml",
"data.xml",
"security/ir.model.access.csv",
],
"qweb": [
"static/src/xml/CreditNote.xml",
"static/src/xml/OrderReceipt.xml",
"static/src/xml/PaymentMethodButton.xml",
"static/src/xml/ReceiptScreen.xml",
"static/src/xml/pos.xml",
],
"demo": ["data/demo.xml"],
"installable": True,
"uninstall_hook": "pre_uninstall",
}
48 changes: 48 additions & 0 deletions pos_debt_notebook/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--Copyright 2014-2016 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
Copyright 2015 Alexis de Lattre <https://github.com/alexis-via>
Copyright 2016 Stanislav Krotov <https://it-projects.info/team/ufaks>
License MIT (https://opensource.org/licenses/MIT). -->
<odoo>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script
type="text/javascript"
src="/pos_debt_notebook/static/src/js/pos.js"
/>
<script
type="text/javascript"
src="/pos_debt_notebook/static/src/js/CreditNote.js"
/>
<script
type="text/javascript"
src="/pos_debt_notebook/static/src/js/OrderReceipt.js"
/>
<script
type="text/javascript"
src="/pos_debt_notebook/static/src/js/ReceiptScreen.js"
/>
<script
type="text/javascript"
src="/pos_debt_notebook/static/src/js/ValidationButton.js"
/>
<script
type="text/javascript"
src="/pos_debt_notebook/static/src/js/DebtHistoryLine.js"
/>
<link
rel="stylesheet"
href="/pos_debt_notebook/static/src/css/pos.css"
id="pos_debt_notebook-stylesheet"
/>
</xpath>
</template>
<template id="demo_assets_backend" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script
type="text/javascript"
src="/pos_debt_notebook/static/src/js/test_pos_debt.js"
/>
</xpath>
</template>
</odoo>
25 changes: 25 additions & 0 deletions pos_debt_notebook/data/demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" ?>
<!--Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
License MIT (https://opensource.org/licenses/MIT). -->
<odoo>
<data>
<!--Set field debt to 'credit' in model pos.config.settings via get_default_debt_type-->
<function
model="ir.config_parameter"
name="set_param"
eval="('pos_debt_notebook.debt_type', 'credit')"
/>
<record id="product_credit_product" model="product.product">
<field name="name">Credits top-up</field>
<field name="default_code">POS-DEBT</field>
<field name="sale_ok" eval="True" />
<field name="available_in_pos" eval="True" />
<field name="list_price">1</field>
<field name="type">service</field>
<field name="uom_id" ref="uom.product_uom_unit" />
<field name="description">
This is a product for purchasing "Credits".
</field>
</record>
</data>
</odoo>
23 changes: 23 additions & 0 deletions pos_debt_notebook/data/product.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" ?>
<!--Copyright 2016 Stanislav Krotov <https://it-projects.info/team/ufaks>
License MIT (https://opensource.org/licenses/MIT). -->
<odoo>
<data noupdate="1">
<record id="product_pay_debt" model="product.product">
<field name="name">Pay Debt</field>
<field name="default_code">POS-DEBT</field>
<field name="sale_ok" eval="True" />
<field name="available_in_pos" eval="True" />
<field name="list_price">0</field>
<field name="type">service</field>
<field name="uom_id" ref="uom.product_uom_unit" />
<field name="taxes_id" eval="[(5,)]" />
<field name="supplier_taxes_id" eval="[(5,)]" />
<field name="description">
This is a dummy product used when a customer pays his debt without
ordering new products. This is a workaround to the fact that Odoo needs
to have at least one product on the order to validate the transaction.
</field>
</record>
</data>
</odoo>
Loading