Payment Orders
This commit is contained in:
parent
e28c88af88
commit
7e13d3b4b1
|
|
@ -10,6 +10,7 @@ class AccountMoveLine(models.Model):
|
|||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
family_confirm_id = fields.Many2one(comodel_name='confirm.benefit.expense', string='Benefit Family')
|
||||
payment_order_id = fields.Many2one(comodel_name='payment.orders', string='Payment Orders')
|
||||
|
||||
benefit_family_ids = fields.Many2many(comodel_name='grant.benefit',relation='account_move_grant_family_rel',
|
||||
column1='move_id',column2='family_id', string='Benefit Family')
|
||||
|
|
@ -30,6 +30,8 @@ class FamilyValidationSetting(models.Model):
|
|||
column1='family_id', column2='categ_id', string='Benefit Categories')
|
||||
|
||||
meal_partner_id = fields.Many2one('res.partner', string='Meal Partner')
|
||||
journal_id = fields.Many2one('account.journal', string='Journal')
|
||||
account_id = fields.Many2one('account.account',string='Expenses Account')
|
||||
|
||||
@api.constrains('meal_expense_account_id', 'clothing_expense_account_id', 'cash_expense_account_id')
|
||||
def _constraint_amount_should_be_positive_if_account_selected(self):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from odoo import fields, models, api, _
|
||||
from stdnum.au.acn import to_abn
|
||||
|
||||
|
||||
class PaymentOrders(models.Model):
|
||||
|
|
@ -11,8 +12,9 @@ class PaymentOrders(models.Model):
|
|||
accountant_id = fields.Many2one('res.users',string='Accountant')
|
||||
payment_order_description = fields.Char(string='Payment Order Description')
|
||||
service_requests_ids = fields.One2many('service.request', 'payment_order_id', string ='Service Requests')
|
||||
total_moves = fields.Integer(string="Total Move Lines", compute='_get_total_moves')
|
||||
state = fields.Selection(string='Status', selection=[('draft', 'Draft'),('accountant_approve', 'accountant Approve'),('department_manager_approve', 'Department Manager Approve')
|
||||
,('accounting_approve', 'Accounting Approve'),('general_manager_approve', 'General Manager Approve'),('refused', 'Refused')])
|
||||
,('accounting_approve', 'Accounting Approve'),('general_manager_approve', 'General Manager Approve'),('refused', 'Refused')],default = 'draft')
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
|
|
@ -28,6 +30,11 @@ class PaymentOrders(models.Model):
|
|||
args += [('accountant_id', '=', self.env.user.id)]
|
||||
return super(PaymentOrders, self).search(args, offset, limit, order, count)
|
||||
|
||||
def _get_total_moves(self):
|
||||
for rec in self:
|
||||
rec.total_moves = self.env['account.move'].search_count([
|
||||
('payment_order_id', '=', rec.id), ('move_type', '!=', 'in_invoice')])
|
||||
|
||||
def action_accountant_approve(self):
|
||||
for rec in self:
|
||||
rec.state = 'accountant_approve'
|
||||
|
|
@ -43,7 +50,61 @@ class PaymentOrders(models.Model):
|
|||
def action_general_manager_approve(self):
|
||||
for rec in self:
|
||||
rec.state = 'general_manager_approve'
|
||||
|
||||
x = self.env['account.move'].create(
|
||||
{
|
||||
'ref': f'{rec.payment_order_description}/{rec.ref_num}',
|
||||
'journal_id': self.env["family.validation.setting"].search([], limit=1).journal_id.id,
|
||||
'payment_order_id': rec.id,
|
||||
'line_ids' : rec.get_lines()
|
||||
}
|
||||
)
|
||||
def action_refuse(self):
|
||||
for rec in self:
|
||||
rec.state = 'refused'
|
||||
rec.state = 'refused'
|
||||
|
||||
def action_open_related_move_records(self):
|
||||
""" Opens a tree view with related records filtered by a dynamic domain """
|
||||
moves = self.env['account.move'].search([
|
||||
('payment_order_id', '=', self.id), ('move_type', '!=', 'in_invoice')
|
||||
]).ids
|
||||
return {
|
||||
'name': _('Moves'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'account.move',
|
||||
'view_mode': 'tree,form',
|
||||
'domain': [('id', 'in', moves)],
|
||||
}
|
||||
def get_lines(self):
|
||||
lines = []
|
||||
total_credit = 0
|
||||
for request in self.service_requests_ids:
|
||||
lines.append(
|
||||
{
|
||||
'account_id' : request.account_id.id,
|
||||
'partner_id' : request.family_id.partner_id.id,
|
||||
# 'branch_id' : request.branch_custom_id.id,
|
||||
'analytic_account_id': request.branch_custom_id.branch.analytic_account_id.id,
|
||||
'debit' : request.aid_amount,
|
||||
'name': f'{"Family code"}{request.family_id.code}-{request.description}-{request.payment_order_id.name}-{request.payment_order_id.ref_num}',
|
||||
}
|
||||
)
|
||||
total_credit += request.aid_amount
|
||||
lines.append({
|
||||
'account_id': self.env["family.validation.setting"].search([], limit=1).account_id.id,
|
||||
'name': f'{self.name}-{self.ref_num}',
|
||||
'credit' : total_credit,
|
||||
})
|
||||
return [(0, 0, line) for line in lines]
|
||||
# def create_entry(self, journal_id, lines):
|
||||
# """Create an account move entry"""
|
||||
# move_vals = {
|
||||
# 'journal_id': journal_id,
|
||||
# 'date': self.date,
|
||||
# 'ref': self.name,
|
||||
# 'family_confirm_id': self.id,
|
||||
# 'benefit_family_ids': [(6, 0, self.family_ids.ids)],
|
||||
# 'line_ids': lines,
|
||||
# }
|
||||
# move_id = self.env['account.move'].create(move_vals)
|
||||
# move_id.action_post()
|
||||
# return True
|
||||
|
|
@ -79,6 +79,7 @@ class ServiceRequest(models.Model):
|
|||
has_money_field_is_appearance = fields.Boolean(string='Has money Field is appearance?',compute='_get_money_field_is_appearance')
|
||||
payment_order_id = fields.Many2one('payment.orders',string='Payment Order')
|
||||
is_payment_order_done = fields.Boolean(string='Is Payment Order Done?')
|
||||
aid_amount = fields.Float(string='Aid Amount',compute='_get_aid_amount')
|
||||
state = fields.Selection([
|
||||
('draft', 'Draft'),
|
||||
('researcher', 'Researcher'),
|
||||
|
|
@ -226,6 +227,12 @@ class ServiceRequest(models.Model):
|
|||
else:
|
||||
rec.has_money_field_is_appearance = False
|
||||
|
||||
def _get_aid_amount(self):
|
||||
for rec in self:
|
||||
if rec.service_type == 'rent':
|
||||
rec.aid_amount = rec.paid_rent_amount
|
||||
else:
|
||||
rec.aid_amount = rec.requested_service_amount
|
||||
def action_for_researcher(self):
|
||||
for rec in self:
|
||||
rec.state = 'researcher'
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@
|
|||
</group>
|
||||
<group>
|
||||
<field name="benefit_category_ids" widget="many2many_tags"/>
|
||||
<field name="journal_id"/>
|
||||
<field name="account_id"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,11 @@
|
|||
<field name="state" widget="statusbar"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box" attrs="{'invisible': [('state','!=','general_manager_approve')]}">
|
||||
<button icon="fa-usd" name="action_open_related_move_records" type="object">
|
||||
<field name="total_moves" string="Moves" widget="statinfo"/>
|
||||
</button>
|
||||
</div>
|
||||
<group>
|
||||
<div class="oe_title">
|
||||
<h1>
|
||||
|
|
@ -45,7 +50,7 @@
|
|||
<field name="account_id"/>
|
||||
<field name="name"/>
|
||||
<field name="description"/>
|
||||
<field name="paid_rent_amount"/>
|
||||
<field name="aid_amount"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@
|
|||
<field name="sub_service_category" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}" required="1"/>
|
||||
<field name="service_cat" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}" required="1"/>
|
||||
<field name="requested_service_amount" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}" required="1"/>
|
||||
<field name="aid_amount" invisible="1"/>
|
||||
<field name="description" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}"/>
|
||||
<field name="service_attach" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}" widget="many2many_attachment_preview"/>
|
||||
<field name="service_type" invisible="1"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue