-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
155 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import models | ||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_l10n_ro_cash_register_user,cash_register user,model_l10n_ro_cash_register,account.group_account_manager,1,1,1,1 | ||
.access_l10n_ro_cash_register_operation,access_l10n_ro_cash_register_operation,model_l10n_ro_cash_register_operation,account.group_account_manager,1,1,1,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import cash_register_operation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class CashRegisterOperation(models.TransientModel): | ||
_name = "l10n.ro.cash.register.operation" | ||
_description = "Cash Register Operation" | ||
|
||
journal_id = fields.Many2one("account.journal", string="Journal", required=True, domain=[("type", "=", "cash")]) | ||
currency_id = fields.Many2one(related="journal_id.currency_id", string="Currency", readonly=True) | ||
date = fields.Date(required=True, default=fields.Date.context_today) | ||
amount = fields.Monetary(string="Amount", required=True) | ||
operation = fields.Selection( | ||
[ | ||
("in", "Cash In"), | ||
("out", "Cash Out"), | ||
], | ||
string="Operation", | ||
required=True, | ||
) | ||
description = fields.Char(string="Description") | ||
|
||
counterpart_account_id = fields.Many2one("account.account", string="Account", required=True) | ||
|
||
def default_get(self, fields_list): | ||
defaults = super().default_get(fields_list) | ||
defaults["account_id"] = self.env.company.transfer_account_id.id | ||
return defaults | ||
|
||
def action_confirm(self): | ||
# se va genra o nota contabila cu operatia | ||
self.ensure_one() | ||
value = { | ||
"journal_id": self.journal_id.id, | ||
"date": self.date, | ||
"ref": self.description, | ||
"line_ids": [ | ||
( | ||
0, | ||
0, | ||
{ | ||
"account_id": self.journal_id.default_account_id.id, | ||
"name": self.description, | ||
"debit" if self.operation == "in" else "credit": self.amount, | ||
}, | ||
), | ||
( | ||
0, | ||
0, | ||
{ | ||
"account_id": self.counterpart_account_id.id, | ||
"name": self.description, | ||
"credit" if self.operation == "in" else "debit": self.amount, | ||
}, | ||
), | ||
], | ||
} | ||
move = self.env["account.move"].create(value) | ||
move._post() |
36 changes: 36 additions & 0 deletions
36
l10n_ro_cash_register/wizard/cash_register_operation_view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<odoo> | ||
<record id="view_cash_register_operation_form" model="ir.ui.view"> | ||
<field name="name">cash.register.operation.form</field> | ||
<field name="model">l10n.ro.cash.register.operation</field> | ||
<field name="arch" type="xml"> | ||
<form string="Cash Register Operation"> | ||
<group> | ||
<group> | ||
<field name="operation" widget="radio" options="{'horizontal': True}" /> | ||
<field name="amount" /> | ||
<field name="currency_id" invisible="1" /> | ||
<field name="description" /> | ||
</group> | ||
<group> | ||
<field name="journal_id" /> | ||
<field name="date" /> | ||
<field name="counterpart_account_id" /> | ||
</group> | ||
</group> | ||
<footer> | ||
<button string="Confirm" type="object" name="action_confirm" class="btn-primary" /> | ||
<button string="Cancel" class="btn-secondary" special="cancel" /> | ||
</footer> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="action_cash_register_operation" model="ir.actions.act_window"> | ||
<field name="name">Cash Register Operation</field> | ||
<field name="res_model">l10n.ro.cash.register.operation</field> | ||
<field name="view_mode">form</field> | ||
<field name="target">new</field> | ||
</record> | ||
|
||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters