diff --git a/ssi_voucher_bank_cash/models/bank_payment.py b/ssi_voucher_bank_cash/models/bank_payment.py index 8a05373..799d7d8 100644 --- a/ssi_voucher_bank_cash/models/bank_payment.py +++ b/ssi_voucher_bank_cash/models/bank_payment.py @@ -27,6 +27,9 @@ def _default_type_id(self): line_ids = fields.One2many( comodel_name="account.bank_payment_line", ) + line_summary_ids = fields.One2many( + comodel_name="account.bank_payment_line_summary", + ) line_dr_ids = fields.One2many( comodel_name="account.bank_payment_line", ) @@ -76,3 +79,77 @@ class BankPaymentLineTax(models.Model): related="voucher_line_id.company_currency_id", store=True, ) + + +class BankPaymentLineSummary(models.Model): + _name = "account.bank_payment_line_summary" + _inherit = "mixin.account.voucher.line.summary" + _description = "Bank Payment Line Summary" + _auto = False + + voucher_id = fields.Many2one( + comodel_name="account.bank_payment", + ) + + def _select(self): + select_str = """ + SELECT + row_number() OVER() as id, + a.voucher_id AS voucher_id, + a.account_id AS account_id, + a.partner_id AS partner_id, + a.currency_id AS currency_id, + SUM(a.amount_before_tax) AS amount_before_tax, + SUM(a.amount_tax) AS amount_tax, + SUM(a.amount_after_tax) AS amount_after_tax + """ + return select_str + + def _get_from_table(self): + return "account_bank_payment_line" + + def _from(self): + from_str = """ + %s AS a + """ % ( + self._get_from_table() + ) + return from_str + + def _where(self): + where_str = """ + WHERE 1 = 1 + """ + return where_str + + def _join(self): + join_str = """ + """ + return join_str + + def _group_by(self): + group_str = """ + GROUP BY a.voucher_id,a.account_id,a.partner_id,a.currency_id + """ + return group_str + + def init(self): + # tools.drop_view_if_exists(self._cr, self._table) + # pylint: disable=locally-disabled, sql-injection + self._cr.execute( + """CREATE or REPLACE VIEW %s as ( + %s + FROM %s + %s + %s + %s + )""" + % ( + self._table, + self._select(), + self._from(), + self._join(), + self._where(), + self._group_by(), + ) + ) diff --git a/ssi_voucher_bank_cash/models/bank_receipt.py b/ssi_voucher_bank_cash/models/bank_receipt.py index 7e086b6..531bccc 100644 --- a/ssi_voucher_bank_cash/models/bank_receipt.py +++ b/ssi_voucher_bank_cash/models/bank_receipt.py @@ -27,6 +27,9 @@ def _default_type_id(self): line_ids = fields.One2many( comodel_name="account.bank_receipt_line", ) + line_summary_ids = fields.One2many( + comodel_name="account.bank_receipt_line_summary", + ) line_dr_ids = fields.One2many( comodel_name="account.bank_receipt_line", ) @@ -76,3 +79,77 @@ class BankReceiptLineTax(models.Model): related="voucher_line_id.company_currency_id", store=True, ) + + +class BankReceiptLineSummary(models.Model): + _name = "account.bank_receipt_line_summary" + _inherit = "mixin.account.voucher.line.summary" + _description = "Bank Receipt Line Summary" + _auto = False + + voucher_id = fields.Many2one( + comodel_name="account.bank_receipt", + ) + + def _select(self): + select_str = """ + SELECT + row_number() OVER() as id, + a.voucher_id AS voucher_id, + a.account_id AS account_id, + a.partner_id AS partner_id, + a.currency_id AS currency_id, + SUM(a.amount_before_tax) AS amount_before_tax, + SUM(a.amount_tax) AS amount_tax, + SUM(a.amount_after_tax) AS amount_after_tax + """ + return select_str + + def _get_from_table(self): + return "account_bank_receipt_line" + + def _from(self): + from_str = """ + %s AS a + """ % ( + self._get_from_table() + ) + return from_str + + def _where(self): + where_str = """ + WHERE 1 = 1 + """ + return where_str + + def _join(self): + join_str = """ + """ + return join_str + + def _group_by(self): + group_str = """ + GROUP BY a.voucher_id,a.account_id,a.partner_id,a.currency_id + """ + return group_str + + def init(self): + # tools.drop_view_if_exists(self._cr, self._table) + # pylint: disable=locally-disabled, sql-injection + self._cr.execute( + """CREATE or REPLACE VIEW %s as ( + %s + FROM %s + %s + %s + %s + )""" + % ( + self._table, + self._select(), + self._from(), + self._join(), + self._where(), + self._group_by(), + ) + ) diff --git a/ssi_voucher_bank_cash/models/cash_payment.py b/ssi_voucher_bank_cash/models/cash_payment.py index b13818c..706cde2 100644 --- a/ssi_voucher_bank_cash/models/cash_payment.py +++ b/ssi_voucher_bank_cash/models/cash_payment.py @@ -27,6 +27,9 @@ def _default_type_id(self): line_ids = fields.One2many( comodel_name="account.cash_payment_line", ) + line_summary_ids = fields.One2many( + comodel_name="account.cash_payment_line_summary", + ) line_dr_ids = fields.One2many( comodel_name="account.cash_payment_line", ) @@ -76,3 +79,77 @@ class CashPaymentLineTax(models.Model): related="voucher_line_id.company_currency_id", store=True, ) + + +class CashPaymentLineSummary(models.Model): + _name = "account.cash_payment_line_summary" + _inherit = "mixin.account.voucher.line.summary" + _description = "Cash Payment Line Summary" + _auto = False + + voucher_id = fields.Many2one( + comodel_name="account.cash_payment", + ) + + def _select(self): + select_str = """ + SELECT + row_number() OVER() as id, + a.voucher_id AS voucher_id, + a.account_id AS account_id, + a.partner_id AS partner_id, + a.currency_id AS currency_id, + SUM(a.amount_before_tax) AS amount_before_tax, + SUM(a.amount_tax) AS amount_tax, + SUM(a.amount_after_tax) AS amount_after_tax + """ + return select_str + + def _get_from_table(self): + return "account_cash_payment_line" + + def _from(self): + from_str = """ + %s AS a + """ % ( + self._get_from_table() + ) + return from_str + + def _where(self): + where_str = """ + WHERE 1 = 1 + """ + return where_str + + def _join(self): + join_str = """ + """ + return join_str + + def _group_by(self): + group_str = """ + GROUP BY a.voucher_id,a.account_id,a.partner_id,a.currency_id + """ + return group_str + + def init(self): + # tools.drop_view_if_exists(self._cr, self._table) + # pylint: disable=locally-disabled, sql-injection + self._cr.execute( + """CREATE or REPLACE VIEW %s as ( + %s + FROM %s + %s + %s + %s + )""" + % ( + self._table, + self._select(), + self._from(), + self._join(), + self._where(), + self._group_by(), + ) + ) diff --git a/ssi_voucher_bank_cash/models/cash_receipt.py b/ssi_voucher_bank_cash/models/cash_receipt.py index 1f0ecf9..8e62926 100644 --- a/ssi_voucher_bank_cash/models/cash_receipt.py +++ b/ssi_voucher_bank_cash/models/cash_receipt.py @@ -26,6 +26,9 @@ def _default_type_id(self): line_ids = fields.One2many( comodel_name="account.cash_receipt_line", ) + line_summary_ids = fields.One2many( + comodel_name="account.cash_receipt_line_summary", + ) line_dr_ids = fields.One2many( comodel_name="account.cash_receipt_line", ) @@ -75,3 +78,77 @@ class CashReceiptLineTax(models.Model): related="voucher_line_id.company_currency_id", store=True, ) + + +class CashReceiptLineSummary(models.Model): + _name = "account.cash_receipt_line_summary" + _inherit = "mixin.account.voucher.line.summary" + _description = "Cash Receipt Line Summary" + _auto = False + + voucher_id = fields.Many2one( + comodel_name="account.cash_receipt", + ) + + def _select(self): + select_str = """ + SELECT + row_number() OVER() as id, + a.voucher_id AS voucher_id, + a.account_id AS account_id, + a.partner_id AS partner_id, + a.currency_id AS currency_id, + SUM(a.amount_before_tax) AS amount_before_tax, + SUM(a.amount_tax) AS amount_tax, + SUM(a.amount_after_tax) AS amount_after_tax + """ + return select_str + + def _get_from_table(self): + return "account_cash_receipt_line" + + def _from(self): + from_str = """ + %s AS a + """ % ( + self._get_from_table() + ) + return from_str + + def _where(self): + where_str = """ + WHERE 1 = 1 + """ + return where_str + + def _join(self): + join_str = """ + """ + return join_str + + def _group_by(self): + group_str = """ + GROUP BY a.voucher_id,a.account_id,a.partner_id,a.currency_id + """ + return group_str + + def init(self): + # tools.drop_view_if_exists(self._cr, self._table) + # pylint: disable=locally-disabled, sql-injection + self._cr.execute( + """CREATE or REPLACE VIEW %s as ( + %s + FROM %s + %s + %s + %s + )""" + % ( + self._table, + self._select(), + self._from(), + self._join(), + self._where(), + self._group_by(), + ) + ) diff --git a/ssi_voucher_bank_cash/security/ir.model.access.csv b/ssi_voucher_bank_cash/security/ir.model.access.csv index 1b49ff7..efea6af 100644 --- a/ssi_voucher_bank_cash/security/ir.model.access.csv +++ b/ssi_voucher_bank_cash/security/ir.model.access.csv @@ -11,6 +11,10 @@ access_bank_receipt_line_tax_all,account.bank_receipt_line_tax - all,model_accou access_bank_receipt_line_tax_viewer,account.bank_receipt_line_tax - viewer,model_account_bank_receipt_line_tax,bank_receipt_viewer_group,1,0,0,0 access_bank_receipt_line_tax_user,account.bank_receipt_line_tax - user,model_account_bank_receipt_line_tax,bank_receipt_user_group,1,1,1,1 access_bank_receipt_line_tax_validator,account.bank_receipt_line_tax – validator,model_account_bank_receipt_line_tax,bank_receipt_validator_group,1,1,1,1 +access_bank_receipt_line_summary_all,account.bank_receipt_line_summary - all,model_account_bank_receipt_line_summary,,1,0,0,0 +access_bank_receipt_line_summary_viewer,account.bank_receipt_line_summary - viewer,model_account_bank_receipt_line_summary,bank_receipt_viewer_group,1,0,0,0 +access_bank_receipt_line_summary_user,account.bank_receipt_line_summary - user,model_account_bank_receipt_line_summary,bank_receipt_user_group,1,1,1,1 +access_bank_receipt_line_summary_validator,account.bank_receipt_line_summary – validator,model_account_bank_receipt_line_summary,bank_receipt_validator_group,1,1,1,1 access_bank_payment_all,account.bank_payment - all,model_account_bank_payment,,1,0,0,0 access_bank_payment_viewer,account.bank_payment - viewer,model_account_bank_payment,bank_payment_viewer_group,1,0,0,0 access_bank_payment_user,account.bank_payment - user,model_account_bank_payment,bank_payment_user_group,1,1,1,1 @@ -23,6 +27,10 @@ access_bank_payment_line_tax_all,account.bank_payment_line_tax - all,model_accou access_bank_payment_line_tax_viewer,account.bank_payment_line_tax - viewer,model_account_bank_payment_line_tax,bank_payment_viewer_group,1,0,0,0 access_bank_payment_line_tax_user,account.bank_payment_line_tax - user,model_account_bank_payment_line_tax,bank_payment_user_group,1,1,1,1 access_bank_payment_line_tax_validator,account.bank_payment_line_tax – validator,model_account_bank_payment_line_tax,bank_payment_validator_group,1,1,1,1 +access_bank_payment_line_summary_all,account.bank_payment_line_summary - all,model_account_bank_payment_line_summary,,1,0,0,0 +access_bank_payment_line_summary_viewer,account.bank_payment_line_summary - viewer,model_account_bank_payment_line_summary,bank_payment_viewer_group,1,0,0,0 +access_bank_payment_line_summary_user,account.bank_payment_line_summary - user,model_account_bank_payment_line_summary,bank_payment_user_group,1,1,1,1 +access_bank_payment_line_summary_validator,account.bank_payment_line_summary – validator,model_account_bank_payment_line_summary,bank_payment_validator_group,1,1,1,1 access_cash_receipt_all,account.cash_receipt - all,model_account_cash_receipt,,1,0,0,0 access_cash_receipt_viewer,account.cash_receipt - viewer,model_account_cash_receipt,cash_receipt_viewer_group,1,0,0,0 access_cash_receipt_user,account.cash_receipt - user,model_account_cash_receipt,cash_receipt_user_group,1,1,1,1 @@ -35,6 +43,10 @@ access_cash_receipt_line_tax_all,account.cash_receipt_line_tax - all,model_accou access_cash_receipt_line_tax_viewer,account.cash_receipt_line_tax - viewer,model_account_cash_receipt_line_tax,cash_receipt_viewer_group,1,0,0,0 access_cash_receipt_line_tax_user,account.cash_receipt_line_tax - user,model_account_cash_receipt_line_tax,cash_receipt_user_group,1,1,1,1 access_cash_receipt_line_tax_validator,account.cash_receipt_line_tax – validator,model_account_cash_receipt_line_tax,cash_receipt_validator_group,1,1,1,1 +access_cash_receipt_line_summary_all,account.cash_receipt_line_summary - all,model_account_cash_receipt_line_summary,,1,0,0,0 +access_cash_receipt_line_summary_viewer,account.cash_receipt_line_summary - viewer,model_account_cash_receipt_line_summary,cash_receipt_viewer_group,1,0,0,0 +access_cash_receipt_line_summary_user,account.cash_receipt_line_summary - user,model_account_cash_receipt_line_summary,cash_receipt_user_group,1,1,1,1 +access_bank_payment_line_summary_validator,account.cash_receipt_line_summary – validator,model_account_cash_receipt_line_summary,cash_receipt_validator_group,1,1,1,1 access_cash_payment_all,account.cash_payment - all,model_account_cash_payment,,1,0,0,0 access_cash_payment_viewer,account.cash_payment - viewer,model_account_cash_payment,cash_payment_viewer_group,1,0,0,0 access_cash_payment_user,account.cash_payment - user,model_account_cash_payment,cash_payment_user_group,1,1,1,1 @@ -47,3 +59,7 @@ access_cash_payment_line_tax_all,account.cash_payment_line_tax - all,model_accou access_cash_payment_line_tax_viewer,account.cash_payment_line_tax - viewer,model_account_cash_payment_line_tax,cash_payment_viewer_group,1,0,0,0 access_cash_payment_line_tax_user,account.cash_payment_line_tax - user,model_account_cash_payment_line_tax,cash_payment_user_group,1,1,1,1 access_cash_payment_line_tax_validator,account.cash_payment_line_tax – validator,model_account_cash_payment_line_tax,cash_payment_validator_group,1,1,1,1 +access_cash_payment_line_summary_all,account.cash_payment_line_summary - all,model_account_cash_payment_line_summary,,1,0,0,0 +access_cash_payment_line_summary_viewer,account.cash_payment_line_summary - viewer,model_account_cash_payment_line_summary,cash_payment_viewer_group,1,0,0,0 +access_cash_payment_line_summary_user,account.cash_payment_line_summary - user,model_account_cash_payment_line_summary,cash_payment_user_group,1,1,1,1 +access_cash_payment_line_summary_validator,account.cash_payment_line_summary – validator,model_account_cash_payment_line_summary,cash_payment_validator_group,1,1,1,1 diff --git a/ssi_voucher_bank_cash/views/account_bank_payment_views.xml b/ssi_voucher_bank_cash/views/account_bank_payment_views.xml index f053d5e..c19e816 100644 --- a/ssi_voucher_bank_cash/views/account_bank_payment_views.xml +++ b/ssi_voucher_bank_cash/views/account_bank_payment_views.xml @@ -43,6 +43,19 @@ name="context" >{'default_type': 'dr', 'default_partner_id':partner_id, 'default_currency_id':currency_id, 'default_company_currency_id':company_currency_id} + + + + + + + + + + + + + diff --git a/ssi_voucher_bank_cash/views/account_bank_receipt_views.xml b/ssi_voucher_bank_cash/views/account_bank_receipt_views.xml index 438fed9..83e39db 100644 --- a/ssi_voucher_bank_cash/views/account_bank_receipt_views.xml +++ b/ssi_voucher_bank_cash/views/account_bank_receipt_views.xml @@ -43,6 +43,19 @@ name="context" >{'default_type': 'cr', 'default_partner_id':partner_id, 'default_currency_id':currency_id, 'default_company_currency_id':company_currency_id} + + + + + + + + + + + + + diff --git a/ssi_voucher_bank_cash/views/account_cash_payment_views.xml b/ssi_voucher_bank_cash/views/account_cash_payment_views.xml index 3d6693d..5e0f432 100644 --- a/ssi_voucher_bank_cash/views/account_cash_payment_views.xml +++ b/ssi_voucher_bank_cash/views/account_cash_payment_views.xml @@ -43,6 +43,19 @@ name="context" >{'default_type': 'dr', 'default_partner_id':partner_id, 'default_currency_id':currency_id, 'default_company_currency_id':company_currency_id} + + + + + + + + + + + + + diff --git a/ssi_voucher_bank_cash/views/account_cash_receipt_views.xml b/ssi_voucher_bank_cash/views/account_cash_receipt_views.xml index eafbe80..e31482a 100644 --- a/ssi_voucher_bank_cash/views/account_cash_receipt_views.xml +++ b/ssi_voucher_bank_cash/views/account_cash_receipt_views.xml @@ -43,6 +43,19 @@ name="context" >{'default_type': 'cr', 'default_partner_id':partner_id, 'default_currency_id':currency_id, 'default_company_currency_id':company_currency_id} + + + + + + + + + + + + + diff --git a/ssi_voucher_cheque/models/cheque_payment.py b/ssi_voucher_cheque/models/cheque_payment.py index 20060c7..b60a224 100644 --- a/ssi_voucher_cheque/models/cheque_payment.py +++ b/ssi_voucher_cheque/models/cheque_payment.py @@ -26,6 +26,9 @@ def _default_type_id(self): line_ids = fields.One2many( comodel_name="account.cheque_payment_line", ) + line_summary_ids = fields.One2many( + comodel_name="account.cheque_payment_line_summary", + ) line_dr_ids = fields.One2many( comodel_name="account.cheque_payment_line", ) @@ -75,3 +78,77 @@ class ChequePaymentLineTax(models.Model): related="voucher_line_id.company_currency_id", store=True, ) + + +class ChequePaymentLineSummary(models.Model): + _name = "account.cheque_payment_line_summary" + _inherit = "mixin.account.voucher.line.summary" + _description = "Cheque Payment Line Summary" + _auto = False + + voucher_id = fields.Many2one( + comodel_name="account.cheque_payment", + ) + + def _select(self): + select_str = """ + SELECT + row_number() OVER() as id, + a.voucher_id AS voucher_id, + a.account_id AS account_id, + a.partner_id AS partner_id, + a.currency_id AS currency_id, + SUM(a.amount_before_tax) AS amount_before_tax, + SUM(a.amount_tax) AS amount_tax, + SUM(a.amount_after_tax) AS amount_after_tax + """ + return select_str + + def _get_from_table(self): + return "account_cheque_payment_line" + + def _from(self): + from_str = """ + %s AS a + """ % ( + self._get_from_table() + ) + return from_str + + def _where(self): + where_str = """ + WHERE 1 = 1 + """ + return where_str + + def _join(self): + join_str = """ + """ + return join_str + + def _group_by(self): + group_str = """ + GROUP BY a.voucher_id,a.account_id,a.partner_id,a.currency_id + """ + return group_str + + def init(self): + # tools.drop_view_if_exists(self._cr, self._table) + # pylint: disable=locally-disabled, sql-injection + self._cr.execute( + """CREATE or REPLACE VIEW %s as ( + %s + FROM %s + %s + %s + %s + )""" + % ( + self._table, + self._select(), + self._from(), + self._join(), + self._where(), + self._group_by(), + ) + ) diff --git a/ssi_voucher_cheque/models/cheque_receipt.py b/ssi_voucher_cheque/models/cheque_receipt.py index 7f0cab7..d3619cd 100644 --- a/ssi_voucher_cheque/models/cheque_receipt.py +++ b/ssi_voucher_cheque/models/cheque_receipt.py @@ -26,6 +26,9 @@ def _default_type_id(self): line_ids = fields.One2many( comodel_name="account.cheque_receipt_line", ) + line_summary_ids = fields.One2many( + comodel_name="account.cheque_receipt_line_summary", + ) line_dr_ids = fields.One2many( comodel_name="account.cheque_receipt_line", ) @@ -75,3 +78,77 @@ class ChequeReceiptLineTax(models.Model): related="voucher_line_id.company_currency_id", store=True, ) + + +class ChequeReceiptLineSummary(models.Model): + _name = "account.cheque_receipt_line_summary" + _inherit = "mixin.account.voucher.line.summary" + _description = "Cheque Receipt Line Summary" + _auto = False + + voucher_id = fields.Many2one( + comodel_name="account.cheque_receipt", + ) + + def _select(self): + select_str = """ + SELECT + row_number() OVER() as id, + a.voucher_id AS voucher_id, + a.account_id AS account_id, + a.partner_id AS partner_id, + a.currency_id AS currency_id, + SUM(a.amount_before_tax) AS amount_before_tax, + SUM(a.amount_tax) AS amount_tax, + SUM(a.amount_after_tax) AS amount_after_tax + """ + return select_str + + def _get_from_table(self): + return "account_cheque_receipt_line" + + def _from(self): + from_str = """ + %s AS a + """ % ( + self._get_from_table() + ) + return from_str + + def _where(self): + where_str = """ + WHERE 1 = 1 + """ + return where_str + + def _join(self): + join_str = """ + """ + return join_str + + def _group_by(self): + group_str = """ + GROUP BY a.voucher_id,a.account_id,a.partner_id,a.currency_id + """ + return group_str + + def init(self): + # tools.drop_view_if_exists(self._cr, self._table) + # pylint: disable=locally-disabled, sql-injection + self._cr.execute( + """CREATE or REPLACE VIEW %s as ( + %s + FROM %s + %s + %s + %s + )""" + % ( + self._table, + self._select(), + self._from(), + self._join(), + self._where(), + self._group_by(), + ) + ) diff --git a/ssi_voucher_cheque/security/ir.model.access.csv b/ssi_voucher_cheque/security/ir.model.access.csv index b15ebf1..7cae3a7 100644 --- a/ssi_voucher_cheque/security/ir.model.access.csv +++ b/ssi_voucher_cheque/security/ir.model.access.csv @@ -11,6 +11,10 @@ access_cheque_receipt_line_tax_all,account.cheque_receipt_line_tax - all,model_a access_cheque_receipt_line_tax_viewer,account.cheque_receipt_line_tax - viewer,model_account_cheque_receipt_line_tax,cheque_receipt_viewer_group,1,0,0,0 access_cheque_receipt_line_tax_user,account.cheque_receipt_line_tax - user,model_account_cheque_receipt_line_tax,cheque_receipt_user_group,1,1,1,1 access_cheque_receipt_line_tax_validator,account.cheque_receipt_line_tax – validator,model_account_cheque_receipt_line_tax,cheque_receipt_validator_group,1,1,1,1 +access_cheque_receipt_line_summary_all,account.cheque_receipt_line_summary - all,model_account_cheque_receipt_line_summary,,1,0,0,0 +access_cheque_receipt_line_summary_viewer,account.cheque_receipt_line_summary - viewer,model_account_cheque_receipt_line_summary,cheque_receipt_viewer_group,1,0,0,0 +access_cheque_receipt_line_summary_user,account.cheque_receipt_line_summary - user,model_account_cheque_receipt_line_summary,cheque_receipt_user_group,1,1,1,1 +access_cheque_receipt_line_summary_validator,account.cheque_receipt_line_summary – validator,model_account_cheque_receipt_line_summary,cheque_receipt_validator_group,1,1,1,1 access_cheque_payment_all,account.cheque_payment - all,model_account_cheque_payment,,1,0,0,0 access_cheque_payment_viewer,account.cheque_payment - viewer,model_account_cheque_payment,cheque_payment_viewer_group,1,0,0,0 access_cheque_payment_user,account.cheque_payment - user,model_account_cheque_payment,cheque_payment_user_group,1,1,1,1 @@ -23,3 +27,7 @@ access_cheque_payment_line_tax_all,account.cheque_payment_line_tax - all,model_a access_cheque_payment_line_tax_viewer,account.cheque_payment_line_tax - viewer,model_account_cheque_payment_line_tax,cheque_payment_viewer_group,1,0,0,0 access_cheque_payment_line_tax_user,account.cheque_payment_line_tax - user,model_account_cheque_payment_line_tax,cheque_payment_user_group,1,1,1,1 access_cheque_payment_line_tax_validator,account.cheque_payment_line_tax – validator,model_account_cheque_payment_line_tax,cheque_payment_validator_group,1,1,1,1 +access_cheque_payment_line_summary_all,account.cheque_payment_line_summary - all,model_account_cheque_payment_line_summary,,1,0,0,0 +access_cheque_payment_line_summary_viewer,account.cheque_payment_line_summary - viewer,model_account_cheque_payment_line_summary,cheque_payment_viewer_group,1,0,0,0 +access_cheque_payment_line_summary_user,account.cheque_payment_line_summary - user,model_account_cheque_payment_line_summary,cheque_payment_user_group,1,1,1,1 +access_cheque_payment_line_summary_validator,account.cheque_payment_line_summary – validator,model_account_cheque_payment_line_summary,cheque_payment_validator_group,1,1,1,1 diff --git a/ssi_voucher_cheque/views/account_cheque_payment_views.xml b/ssi_voucher_cheque/views/account_cheque_payment_views.xml index 341ece8..4aea5e3 100644 --- a/ssi_voucher_cheque/views/account_cheque_payment_views.xml +++ b/ssi_voucher_cheque/views/account_cheque_payment_views.xml @@ -46,6 +46,19 @@ name="context" >{'default_type': 'dr', 'default_partner_id':partner_id, 'default_currency_id':currency_id, 'default_company_currency_id':company_currency_id} + + + + + + + + + + + + + diff --git a/ssi_voucher_cheque/views/account_cheque_receipt_views.xml b/ssi_voucher_cheque/views/account_cheque_receipt_views.xml index 8e8eddb..20a01b3 100644 --- a/ssi_voucher_cheque/views/account_cheque_receipt_views.xml +++ b/ssi_voucher_cheque/views/account_cheque_receipt_views.xml @@ -44,6 +44,19 @@ name="context" >{'default_type': 'cr', 'default_partner_id':partner_id, 'default_currency_id':currency_id, 'default_company_currency_id':company_currency_id} + + + + + + + + + + + + + diff --git a/ssi_voucher_giro/models/giro_payment.py b/ssi_voucher_giro/models/giro_payment.py index b2cfee1..20e5100 100644 --- a/ssi_voucher_giro/models/giro_payment.py +++ b/ssi_voucher_giro/models/giro_payment.py @@ -26,6 +26,9 @@ def _default_type_id(self): line_ids = fields.One2many( comodel_name="account.giro_payment_line", ) + line_summary_ids = fields.One2many( + comodel_name="account.giro_payment_line_summary", + ) line_dr_ids = fields.One2many( comodel_name="account.giro_payment_line", ) @@ -75,3 +78,77 @@ class GiroPaymentLineTax(models.Model): related="voucher_line_id.company_currency_id", store=True, ) + + +class GiroPaymentLineSummary(models.Model): + _name = "account.giro_payment_line_summary" + _inherit = "mixin.account.voucher.line.summary" + _description = "Giro Payment Line Summary" + _auto = False + + voucher_id = fields.Many2one( + comodel_name="account.giro_payment", + ) + + def _select(self): + select_str = """ + SELECT + row_number() OVER() as id, + a.voucher_id AS voucher_id, + a.account_id AS account_id, + a.partner_id AS partner_id, + a.currency_id AS currency_id, + SUM(a.amount_before_tax) AS amount_before_tax, + SUM(a.amount_tax) AS amount_tax, + SUM(a.amount_after_tax) AS amount_after_tax + """ + return select_str + + def _get_from_table(self): + return "account_giro_payment_line" + + def _from(self): + from_str = """ + %s AS a + """ % ( + self._get_from_table() + ) + return from_str + + def _where(self): + where_str = """ + WHERE 1 = 1 + """ + return where_str + + def _join(self): + join_str = """ + """ + return join_str + + def _group_by(self): + group_str = """ + GROUP BY a.voucher_id,a.account_id,a.partner_id,a.currency_id + """ + return group_str + + def init(self): + # tools.drop_view_if_exists(self._cr, self._table) + # pylint: disable=locally-disabled, sql-injection + self._cr.execute( + """CREATE or REPLACE VIEW %s as ( + %s + FROM %s + %s + %s + %s + )""" + % ( + self._table, + self._select(), + self._from(), + self._join(), + self._where(), + self._group_by(), + ) + ) diff --git a/ssi_voucher_giro/models/giro_receipt.py b/ssi_voucher_giro/models/giro_receipt.py index 521f4ec..2ab6dbd 100644 --- a/ssi_voucher_giro/models/giro_receipt.py +++ b/ssi_voucher_giro/models/giro_receipt.py @@ -26,6 +26,9 @@ def _default_type_id(self): line_ids = fields.One2many( comodel_name="account.giro_receipt_line", ) + line_summary_ids = fields.One2many( + comodel_name="account.giro_receipt_line_summary", + ) line_dr_ids = fields.One2many( comodel_name="account.giro_receipt_line", ) @@ -75,3 +78,77 @@ class GiroReceiptLineTax(models.Model): related="voucher_line_id.company_currency_id", store=True, ) + + +class GiroReceiptLineSummary(models.Model): + _name = "account.giro_receipt_line_summary" + _inherit = "mixin.account.voucher.line.summary" + _description = "Giro Receipt Line Summary" + _auto = False + + voucher_id = fields.Many2one( + comodel_name="account.giro_receipt", + ) + + def _select(self): + select_str = """ + SELECT + row_number() OVER() as id, + a.voucher_id AS voucher_id, + a.account_id AS account_id, + a.partner_id AS partner_id, + a.currency_id AS currency_id, + SUM(a.amount_before_tax) AS amount_before_tax, + SUM(a.amount_tax) AS amount_tax, + SUM(a.amount_after_tax) AS amount_after_tax + """ + return select_str + + def _get_from_table(self): + return "account_giro_receipt_line" + + def _from(self): + from_str = """ + %s AS a + """ % ( + self._get_from_table() + ) + return from_str + + def _where(self): + where_str = """ + WHERE 1 = 1 + """ + return where_str + + def _join(self): + join_str = """ + """ + return join_str + + def _group_by(self): + group_str = """ + GROUP BY a.voucher_id,a.account_id,a.partner_id,a.currency_id + """ + return group_str + + def init(self): + # tools.drop_view_if_exists(self._cr, self._table) + # pylint: disable=locally-disabled, sql-injection + self._cr.execute( + """CREATE or REPLACE VIEW %s as ( + %s + FROM %s + %s + %s + %s + )""" + % ( + self._table, + self._select(), + self._from(), + self._join(), + self._where(), + self._group_by(), + ) + ) diff --git a/ssi_voucher_giro/security/ir.model.access.csv b/ssi_voucher_giro/security/ir.model.access.csv index daa12d9..a142234 100644 --- a/ssi_voucher_giro/security/ir.model.access.csv +++ b/ssi_voucher_giro/security/ir.model.access.csv @@ -11,6 +11,10 @@ access_giro_receipt_line_tax_all,account.giro_receipt_line_tax - all,model_accou access_giro_receipt_line_tax_viewer,account.giro_receipt_line_tax - viewer,model_account_giro_receipt_line_tax,giro_receipt_viewer_group,1,0,0,0 access_giro_receipt_line_tax_user,account.giro_receipt_line_tax - user,model_account_giro_receipt_line_tax,giro_receipt_user_group,1,1,1,1 access_giro_receipt_line_tax_validator,account.giro_receipt_line_tax – validator,model_account_giro_receipt_line_tax,giro_receipt_validator_group,1,1,1,1 +access_giro_receipt_line_summary_all,account.giro_receipt_line_summary - all,model_account_giro_receipt_line_summary,,1,0,0,0 +access_giro_receipt_line_summary_viewer,account.giro_receipt_line_summary - viewer,model_account_giro_receipt_line_summary,giro_receipt_viewer_group,1,0,0,0 +access_giro_receipt_line_summary_user,account.giro_receipt_line_summary - user,model_account_giro_receipt_line_summary,giro_receipt_user_group,1,1,1,1 +access_giro_receipt_line_summary_validator,account.giro_receipt_line_summary – validator,model_account_giro_receipt_line_summary,giro_receipt_validator_group,1,1,1,1 access_giro_payment_all,account.giro_payment - all,model_account_giro_payment,,1,0,0,0 access_giro_payment_viewer,account.giro_payment - viewer,model_account_giro_payment,giro_payment_viewer_group,1,0,0,0 access_giro_payment_user,account.giro_payment - user,model_account_giro_payment,giro_payment_user_group,1,1,1,1 @@ -23,3 +27,7 @@ access_giro_payment_line_tax_all,account.giro_payment_line_tax - all,model_accou access_giro_payment_line_tax_viewer,account.giro_payment_line_tax - viewer,model_account_giro_payment_line_tax,giro_payment_viewer_group,1,0,0,0 access_giro_payment_line_tax_user,account.giro_payment_line_tax - user,model_account_giro_payment_line_tax,giro_payment_user_group,1,1,1,1 access_giro_payment_line_tax_validator,account.giro_payment_line_tax – validator,model_account_giro_payment_line_tax,giro_payment_validator_group,1,1,1,1 +access_giro_payment_line_summary_all,account.giro_payment_line_summary - all,model_account_giro_payment_line_summary,,1,0,0,0 +access_giro_payment_line_summary_viewer,account.giro_payment_line_summary - viewer,model_account_giro_payment_line_summary,giro_payment_viewer_group,1,0,0,0 +access_giro_payment_line_summary_user,account.giro_payment_line_summary - user,model_account_giro_payment_line_summary,giro_payment_user_group,1,1,1,1 +access_giro_payment_line_summary_validator,account.giro_payment_line_summary – validator,model_account_giro_payment_line_summary,giro_payment_validator_group,1,1,1,1 diff --git a/ssi_voucher_giro/views/account_giro_payment_views.xml b/ssi_voucher_giro/views/account_giro_payment_views.xml index ffa13db..b5e9b78 100644 --- a/ssi_voucher_giro/views/account_giro_payment_views.xml +++ b/ssi_voucher_giro/views/account_giro_payment_views.xml @@ -45,6 +45,19 @@ name="context" >{'default_type': 'dr', 'default_partner_id':partner_id, 'default_currency_id':currency_id, 'default_company_currency_id':company_currency_id} + + + + + + + + + + + + + diff --git a/ssi_voucher_giro/views/account_giro_receipt_views.xml b/ssi_voucher_giro/views/account_giro_receipt_views.xml index a17b2f0..362d064 100644 --- a/ssi_voucher_giro/views/account_giro_receipt_views.xml +++ b/ssi_voucher_giro/views/account_giro_receipt_views.xml @@ -43,6 +43,19 @@ name="context" >{'default_type': 'cr', 'default_partner_id':partner_id, 'default_currency_id':currency_id, 'default_company_currency_id':company_currency_id} + + + + + + + + + + + + + diff --git a/ssi_voucher_mixin/README.rst b/ssi_voucher_mixin/README.rst index 3b45963..3e3d374 100644 --- a/ssi_voucher_mixin/README.rst +++ b/ssi_voucher_mixin/README.rst @@ -28,6 +28,7 @@ Contributors * Andhitia Rama * Michael Viriyananda +* Miftahussalam Maintainer ---------- diff --git a/ssi_voucher_mixin/models/__init__.py b/ssi_voucher_mixin/models/__init__.py index 88770fa..d6ca1a8 100644 --- a/ssi_voucher_mixin/models/__init__.py +++ b/ssi_voucher_mixin/models/__init__.py @@ -8,4 +8,5 @@ voucher_mixin, voucher_line_mixin, voucher_line_tax_mixin, + voucher_line_summary_mixin, ) diff --git a/ssi_voucher_mixin/models/voucher_line_summary_mixin.py b/ssi_voucher_mixin/models/voucher_line_summary_mixin.py new file mode 100644 index 0000000..b5d7d06 --- /dev/null +++ b/ssi_voucher_mixin/models/voucher_line_summary_mixin.py @@ -0,0 +1,40 @@ +# Copyright 2024 OpenSynergy Indonesia +# Copyright 2024 PT. Simetri Sinergi Indonesia +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class MixinAccountVoucherLineSummary(models.AbstractModel): + _name = "mixin.account.voucher.line.summary" + _description = "Abstract Class for Account Voucher Line Summary" + _auto = False + + voucher_id = fields.Many2one( + string="Voucher", + comodel_name="mixin.account.voucher", + ) + partner_id = fields.Many2one( + string="Partner", + comodel_name="res.partner", + ) + account_id = fields.Many2one( + string="Account", + comodel_name="account.account", + ) + currency_id = fields.Many2one( + string="Currency", + comodel_name="res.currency", + ) + amount_before_tax = fields.Monetary( + string="Amount Before Tax", + currency_field="currency_id", + ) + amount_tax = fields.Monetary( + string="Amount Tax", + currency_field="currency_id", + ) + amount_after_tax = fields.Monetary( + string="Amount After Tax", + currency_field="currency_id", + ) diff --git a/ssi_voucher_mixin/models/voucher_mixin.py b/ssi_voucher_mixin/models/voucher_mixin.py index 44db527..53ff9c2 100644 --- a/ssi_voucher_mixin/models/voucher_mixin.py +++ b/ssi_voucher_mixin/models/voucher_mixin.py @@ -375,6 +375,12 @@ def _compute_amount(self): default="draft", copy=False, ) + line_summary_ids = fields.One2many( + string="Voucher Line Summary", + comodel_name="mixin.account.voucher.line.summary", + inverse_name="voucher_id", + readonly=True, + ) def action_cancel(self, cancel_reason=False): _super = super(MixinAccountVoucher, self)