Skip to content

Commit

Permalink
[NEW] lcc_credit_requests_from_contracts: create add-on
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphan Sainléger committed Jan 15, 2024
1 parent ef0b282 commit e0c4fe4
Show file tree
Hide file tree
Showing 10 changed files with 858 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lcc_credit_requests_from_contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.*~
*pyc
661 changes: 661 additions & 0 deletions lcc_credit_requests_from_contracts/LICENSE

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions lcc_credit_requests_from_contracts/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
==================================
lcc_credit_requests_from_contracts
==================================

Generate lcc credit requests from contracts

Installation
============

Use Odoo normal module installation procedure to install
``lcc_credit_requests_from_contracts``.

Known issues / Roadmap
======================

None yet.

Bug Tracker
===========

Bugs are tracked on `our issues website <https://github.com/elabore-coop/lcc_credit_requests_from_contracts/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
=======

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

* Stéphan Sainléger - `Email<mailto:stephan.sainleger@elabore.coop>` - `Github<https://github.com/stephansainleger>`

Funders
-------

The development of this module has been financially supported by:
* Elabore (https://elabore.coop)
* Lokavaluto (https://lokavaluto.fr)


Maintainer
----------

This module is maintained by Elabore.
1 change: 1 addition & 0 deletions lcc_credit_requests_from_contracts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
36 changes: 36 additions & 0 deletions lcc_credit_requests_from_contracts/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2024 Elabore
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "lcc_credit_requests_from_contracts",
"version": "12.0.1.0.0",
"author": "Elabore",
"website": "https://elabore.coop",
"maintainer": "Stéphan Sainléger",
"license": "AGPL-3",
"category": "Tools",
"summary": "Generate lcc credit requests from contracts",
# any module necessary for this one to work correctly
"depends": [
"base",
"contract",
"lcc_lokavaluto_app_connection",
],
"qweb": [],
"external_dependencies": {
"python": [],
},
# always loaded
"data": [
"views/contract.xml",
],
# only loaded in demonstration mode
"demo": [],
"js": [],
"css": [],
"installable": True,
# Install this module automatically if all dependency have been previously
# and independently installed. Used for synergetic or glue modules.
"auto_install": False,
"application": False,
}
32 changes: 32 additions & 0 deletions lcc_credit_requests_from_contracts/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * lcc_credit_requests_from_contracts
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-15 12:29+0000\n"
"PO-Revision-Date: 2024-01-15 12:29+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: lcc_credit_requests_from_contracts
#: model:ir.model,name:lcc_credit_requests_from_contracts.model_contract_contract
msgid "Contract"
msgstr "Contrat"

#. module: lcc_credit_requests_from_contracts
#: model:ir.model.fields,field_description:lcc_credit_requests_from_contracts.field_contract_contract__create_credit_requests
msgid "Create Credit Requests"
msgstr "Créer des demandes de chargement"

#. module: lcc_credit_requests_from_contracts
#: model:ir.model.fields,field_description:lcc_credit_requests_from_contracts.field_contract_contract__wallet_id
msgid "Wallet to credit"
msgstr "Portefeuille"

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * lcc_credit_requests_from_contracts
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-15 12:29+0000\n"
"PO-Revision-Date: 2024-01-15 12:29+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: lcc_credit_requests_from_contracts
#: model:ir.model,name:lcc_credit_requests_from_contracts.model_contract_contract
msgid "Contract"
msgstr ""

#. module: lcc_credit_requests_from_contracts
#: model:ir.model.fields,field_description:lcc_credit_requests_from_contracts.field_contract_contract__create_credit_requests
msgid "Create Credit Requests"
msgstr ""

#. module: lcc_credit_requests_from_contracts
#: model:ir.model.fields,field_description:lcc_credit_requests_from_contracts.field_contract_contract__wallet_id
msgid "Wallet to credit"
msgstr ""

1 change: 1 addition & 0 deletions lcc_credit_requests_from_contracts/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import contract
28 changes: 28 additions & 0 deletions lcc_credit_requests_from_contracts/models/contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from odoo import fields, models


class ContractContract(models.Model):
_inherit = 'contract.contract'

create_credit_requests = fields.Boolean('Create Credit Requests')
wallet_id = fields.Many2one('res.partner.backend', string='Wallet to credit')

def _prepare_credit_request_values(self, invoice):
values = {
"amount" : invoice.amount_total,
"partner_id": invoice.partner_id.id,
"wallet_id": self.wallet_id.id,
"invoice_id": invoice.id,
"create_order": False
}
return values

def _recurring_create_invoice(self, date_ref=False):
invoices = super()._recurring_create_invoice(date_ref)
if not (self.create_credit_requests and self.wallet_id):
return invoices
for invoice in invoices:
if invoice.has_numeric_lcc_products:
values = self._prepare_credit_request_values(invoice)
self.env["credit.request"].create(values)
return invoices
20 changes: 20 additions & 0 deletions lcc_credit_requests_from_contracts/views/contract.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="contract_contract_form_view_inherit_credit_request" model="ir.ui.view">
<field name="name">contract.view.form.inherit.credit.request</field>
<field name="model">contract.contract</field>
<field name="inherit_id" ref="contract.contract_contract_form_view" />
<field name="arch" type="xml">
<xpath expr="//group[@name='recurring_invoices']" position="inside">
<group name="credit_requests">
<field name="partner_id" invisible="1" />
<field name="create_credit_requests" />
<field name="wallet_id" domain="[('partner_id','=', partner_id)]"
attrs="{'invisible': [('create_credit_requests','=',False)]}" />
</group>
</xpath>
</field>
</record>
</data>
</odoo>

0 comments on commit e0c4fe4

Please sign in to comment.