Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
1
account_cash_deposit/wizards/__init__.py
Executable file
1
account_cash_deposit/wizards/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from . import account_cash_order_reception
|
||||
41
account_cash_deposit/wizards/account_cash_order_reception.py
Executable file
41
account_cash_deposit/wizards/account_cash_order_reception.py
Executable file
@@ -0,0 +1,41 @@
|
||||
# Copyright 2022 Akretion France (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tools.misc import format_date
|
||||
|
||||
|
||||
class AccountCashOrderReception(models.TransientModel):
|
||||
_name = "account.cash.order.reception"
|
||||
_description = "Cash Order Reception"
|
||||
|
||||
order_id = fields.Many2one(
|
||||
"account.cash.deposit", readonly=True, string="Cash Order"
|
||||
)
|
||||
date = fields.Date(
|
||||
string="Cash Reception Date", default=fields.Date.context_today, required=True
|
||||
)
|
||||
total_amount = fields.Monetary(related="order_id.total_amount")
|
||||
currency_id = fields.Many2one(related="order_id.currency_id")
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields_list):
|
||||
res = super().default_get(fields_list)
|
||||
res["order_id"] = self._context.get("active_id")
|
||||
assert self._context.get("active_model") == "account.cash.deposit"
|
||||
return res
|
||||
|
||||
def run(self):
|
||||
self.ensure_one()
|
||||
today = fields.Date.context_today(self)
|
||||
if self.date > today:
|
||||
raise UserError(
|
||||
_("The Cash Reception Date (%s) is in the future.")
|
||||
% format_date(self.env, self.date)
|
||||
)
|
||||
self.order_id.message_post(
|
||||
body=_("Cash reception confirmed on %s.") % format_date(self.env, self.date)
|
||||
)
|
||||
self.order_id.validate(force_date=self.date)
|
||||
40
account_cash_deposit/wizards/account_cash_order_reception_view.xml
Executable file
40
account_cash_deposit/wizards/account_cash_order_reception_view.xml
Executable file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!--
|
||||
Copyright 2022 Akretion France (http://www.akretion.com/)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
<odoo>
|
||||
<record id="account_cash_order_reception_form" model="ir.ui.view">
|
||||
<field name="model">account.cash.order.reception</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<group name="main">
|
||||
<field name="order_id" />
|
||||
<field
|
||||
name="date"
|
||||
options="{'datepicker': {'warn_future': true}}"
|
||||
/>
|
||||
<field name="total_amount" />
|
||||
<field name="currency_id" invisible="1" />
|
||||
</group>
|
||||
<footer>
|
||||
<button
|
||||
name="run"
|
||||
type="object"
|
||||
string="Confirm Cash Reception"
|
||||
class="btn-primary"
|
||||
/>
|
||||
<button special="cancel" string="Cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="account_cash_order_reception_action" model="ir.actions.act_window">
|
||||
<field name="name">Cash Order Reception</field>
|
||||
<field name="res_model">account.cash.order.reception</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user