[NEW] Addons creation - product_rental_security_deposit

This commit is contained in:
Stéphan Sainléger
2022-04-19 11:56:26 +02:00
parent 5409d5248b
commit 0f3a9c761f
6 changed files with 143 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import models

View File

@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
{
"name": "Product Rental Security Deposit",
"category": "Product",
"version": "14.0.1.0",
"summary": "Manage security deposits in your rental contracts",
"author": "Elabore",
"website": "https://elabore.coop/",
"installable": True,
"application": False,
"auto_install": False,
"description": """
===============================
Product Rental Security Deposit
===============================
This module allows to manage security deposits in rental contracts.
Installation
============
Just install product_rental_security_deposit, all dependencies will be installed by default.
Known issues / Roadmap
======================
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/elabore-coop/.../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
------
* Elabore: `Icon <https://elabore.coop/web/image/res.company/1/logo?unique=f3db262>`_.
Contributors
------------
* Stéphan Sainléger <https://github.com/stephansainleger>
Funders
-------
The development of this module has been financially supported by:
* Elabore (https://elabore.coop)
Maintainer
----------
This module is maintained by ELABORE.
""",
"depends": [
"product_rental_bookings",
],
"data": [
"views/product_contract.xml",
],
"qweb": [],
}

View File

@@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_rental_inspection
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-09-29 14:44+0000\n"
"PO-Revision-Date: 2021-09-29 14:44+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: product_rental_security_deposit
#: model:ir.model.fields,field_description:product_rental_security_deposit.field_rental_product_contract__security_deposit
msgid "Security Deposit"
msgstr "Caution"

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import product_contract

View File

@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
from logging import setLogRecordFactory
from odoo import fields, api, models, _
class RentalProductContract(models.Model):
_inherit = "rental.product.contract"
security_deposit = fields.Monetary(string=_("Security Deposit"))
@api.onchange("security_deposit")
def add_security_deposit(self):
if self.security_deposit and self.product_contract_lines_ids:
line_id = self.product_contract_lines_ids.filtered(
lambda x: x.description == "Deposit"
)
if line_id:
line_id.price = self.security_deposit
else:
self.write(
{
"product_contract_lines_ids": [
(
0,
0,
{
"description": "Deposit",
"enter_days": 1.0,
"price": self.security_deposit,
},
)
]
}
)
@api.depends("product_contract_lines_ids", "security_deposit")
def _compute_amount(self):
super(RentalProductContract, self)._compute_amount()

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id='rental_product_contract_deposit_form' model="ir.ui.view">
<field name="name">Rental Contracts Deposit</field>
<field name="model">rental.product.contract</field>
<field name="inherit_id" ref="product_rental_bookings.rental_product_contract_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='account_payment_term']" position="after">
<field name="security_deposit" widget="monetary" options="{'currency_field': 'currency_id'}" invisible="1" />
</xpath>
</field>
</record>
</data>
</odoo>