From d958068582a637dfec164282134ea6e677ea7717 Mon Sep 17 00:00:00 2001 From: "Tommy (tong)" Date: Fri, 1 Apr 2022 02:07:34 +0000 Subject: [PATCH] [ADD] l10n_ph - add philippines localization task-2713149 closes odoo/odoo#105062 X-original-commit: 60b9738f7923135ec018fbdcd2cbbfa6de8c75e0 Signed-off-by: Florian Gilbert (flg) --- addons/l10n_ph/__init__.py | 4 + addons/l10n_ph/__manifest__.py | 35 + .../l10n_ph/data/account.account.template.csv | 98 ++ .../account_chart_template_configure_data.xml | 6 + .../data/account_chart_template_data.xml | 13 + .../data/account_chart_template_post_data.xml | 18 + .../account_fiscal_position_tax_template.xml | 24 + .../data/account_fiscal_position_template.xml | 18 + addons/l10n_ph/data/account_tax_group.xml | 27 + addons/l10n_ph/data/account_tax_template.xml | 1049 +++++++++++++++++ addons/l10n_ph/models/__init__.py | 7 + addons/l10n_ph/models/account_move.py | 19 + addons/l10n_ph/models/account_payment.py | 19 + addons/l10n_ph/models/account_tax.py | 9 + addons/l10n_ph/models/account_tax_template.py | 14 + addons/l10n_ph/models/res_partner.py | 22 + addons/l10n_ph/security/ir.model.access.csv | 2 + addons/l10n_ph/views/account_move_views.xml | 12 + .../l10n_ph/views/account_payment_views.xml | 12 + addons/l10n_ph/views/account_tax_views.xml | 19 + addons/l10n_ph/views/res_partner_views.xml | 16 + addons/l10n_ph/wizard/__init__.py | 3 + addons/l10n_ph/wizard/generate_2307_wizard.py | 93 ++ .../wizard/generate_2307_wizard_views.xml | 36 + 24 files changed, 1575 insertions(+) create mode 100644 addons/l10n_ph/__init__.py create mode 100644 addons/l10n_ph/__manifest__.py create mode 100644 addons/l10n_ph/data/account.account.template.csv create mode 100644 addons/l10n_ph/data/account_chart_template_configure_data.xml create mode 100644 addons/l10n_ph/data/account_chart_template_data.xml create mode 100644 addons/l10n_ph/data/account_chart_template_post_data.xml create mode 100644 addons/l10n_ph/data/account_fiscal_position_tax_template.xml create mode 100644 addons/l10n_ph/data/account_fiscal_position_template.xml create mode 100644 addons/l10n_ph/data/account_tax_group.xml create mode 100644 addons/l10n_ph/data/account_tax_template.xml create mode 100644 addons/l10n_ph/models/__init__.py create mode 100644 addons/l10n_ph/models/account_move.py create mode 100644 addons/l10n_ph/models/account_payment.py create mode 100644 addons/l10n_ph/models/account_tax.py create mode 100644 addons/l10n_ph/models/account_tax_template.py create mode 100644 addons/l10n_ph/models/res_partner.py create mode 100644 addons/l10n_ph/security/ir.model.access.csv create mode 100644 addons/l10n_ph/views/account_move_views.xml create mode 100644 addons/l10n_ph/views/account_payment_views.xml create mode 100644 addons/l10n_ph/views/account_tax_views.xml create mode 100644 addons/l10n_ph/views/res_partner_views.xml create mode 100644 addons/l10n_ph/wizard/__init__.py create mode 100644 addons/l10n_ph/wizard/generate_2307_wizard.py create mode 100644 addons/l10n_ph/wizard/generate_2307_wizard_views.xml diff --git a/addons/l10n_ph/__init__.py b/addons/l10n_ph/__init__.py new file mode 100644 index 00000000000..33bbab569d0 --- /dev/null +++ b/addons/l10n_ph/__init__.py @@ -0,0 +1,4 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import models +from . import wizard diff --git a/addons/l10n_ph/__manifest__.py b/addons/l10n_ph/__manifest__.py new file mode 100644 index 00000000000..5adefaf116a --- /dev/null +++ b/addons/l10n_ph/__manifest__.py @@ -0,0 +1,35 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +{ + "name": "Philippines - Accounting", + "summary": """ + This is the module to manage the accounting chart for The Philippines. + """, + "category": "Accounting/Localizations/Account Charts", + "version": "1.0", + "author": "Odoo PS", + "website": "https://www.odoo.com", + "depends": [ + "account", + "base_vat", + "l10n_multilang", + ], + "data": [ + "data/account_chart_template_data.xml", + "data/account.account.template.csv", + "data/account_chart_template_post_data.xml", + "data/account_tax_group.xml", + "data/account_tax_template.xml", + "data/account_fiscal_position_template.xml", + "data/account_fiscal_position_tax_template.xml", + "data/account_chart_template_configure_data.xml", + "wizard/generate_2307_wizard_views.xml", + "views/account_move_views.xml", + "views/account_payment_views.xml", + "views/account_tax_views.xml", + "views/res_partner_views.xml", + "security/ir.model.access.csv", + ], + "license": "LGPL-3", + "icon": "/base/static/img/country_flags/ph.png", +} diff --git a/addons/l10n_ph/data/account.account.template.csv b/addons/l10n_ph/data/account.account.template.csv new file mode 100644 index 00000000000..0efec4105dc --- /dev/null +++ b/addons/l10n_ph/data/account.account.template.csv @@ -0,0 +1,98 @@ +id,name,code,account_type,chart_template_id/id,reconcile +l10n_ph_100000,Bank Suspense Account,100000,asset_current,l10n_ph_chart_template,False +l10n_ph_110000,Accounts Receivable,110000,asset_receivable,l10n_ph_chart_template,True +l10n_ph_110003,Accounts Receivable (POS),110003,asset_receivable,l10n_ph_chart_template,True +l10n_ph_110100,Advances to Suppliers,110100,asset_prepayments,l10n_ph_chart_template,False +l10n_ph_110101,Deposits,110101,asset_prepayments,l10n_ph_chart_template,False +l10n_ph_110102,Employees Receivable-Cash Advance,110102,asset_current,l10n_ph_chart_template,False +l10n_ph_110103,Employees Receivable-Loan,110103,asset_current,l10n_ph_chart_template,False +l10n_ph_110104,ER - Others,110104,asset_current,l10n_ph_chart_template,False +l10n_ph_110105,Prepaid Insurance,110105,asset_prepayments,l10n_ph_chart_template,False +l10n_ph_110106,Prepaid Pension - contribution,110106,asset_prepayments,l10n_ph_chart_template,False +l10n_ph_110200,Prepaid Tax - Tax Credit Certificate,110200,asset_current,l10n_ph_chart_template,False +l10n_ph_110201,Input VAT 12%,110201,asset_current,l10n_ph_chart_template,False +l10n_ph_110202,Deferred Input VAT 12%,110202,asset_current,l10n_ph_chart_template,False +l10n_ph_110203,Deferred Tax Asset,110203,asset_current,l10n_ph_chart_template,False +l10n_ph_110205,Creditable Income Tax,110205,asset_current,l10n_ph_chart_template,False +l10n_ph_110206,Tax Withheld by Customer,110206,asset_current,l10n_ph_chart_template,False +l10n_ph_110207,Deferred Tax Withheld by Customer,110207,asset_current,l10n_ph_chart_template,False +l10n_ph_110300,Inventory,110300,asset_current,l10n_ph_chart_template,False +l10n_ph_110301,Purchases,110301,asset_current,l10n_ph_chart_template,False +l10n_ph_110302,Stock Interim (Received),110302,asset_current,l10n_ph_chart_template,True +l10n_ph_110303,Stock Interim (Delivered),110303,asset_current,l10n_ph_chart_template,True +l10n_ph_110304,Stock Interim (Production),110304,asset_current,l10n_ph_chart_template,True +l10n_ph_110400,Other Non-current Asset,110400,asset_non_current,l10n_ph_chart_template,False +l10n_ph_110500,Building and Leasehold Improvements,110500,asset_fixed,l10n_ph_chart_template,False +l10n_ph_110501,"Furniture, Fixtures and Equipment",110501,asset_fixed,l10n_ph_chart_template,False +l10n_ph_110502,Vehicles,110502,asset_fixed,l10n_ph_chart_template,False +l10n_ph_110503,Computers,110503,asset_fixed,l10n_ph_chart_template,False +l10n_ph_110504,Accum Depreciation-Bldg & Leasehold Imp,110504,asset_fixed,l10n_ph_chart_template,False +l10n_ph_110505,"Accum Depreciation-Furniture, Fixtures and Equipment",110505,asset_fixed,l10n_ph_chart_template,False +l10n_ph_110506,Accum Depreciation-Vehicles,110506,asset_fixed,l10n_ph_chart_template,False +l10n_ph_110507,Accum Depreciation-Computers,110507,asset_fixed,l10n_ph_chart_template,False +l10n_ph_200000,Accounts Payable,200000,liability_payable,l10n_ph_chart_template,True +l10n_ph_200200,Dividends Payable - Common Shares,200200,liability_current,l10n_ph_chart_template,False +l10n_ph_200201,Unearned Revenue,200201,liability_current,l10n_ph_chart_template,False +l10n_ph_200202,Customer Deposits Received,200202,liability_current,l10n_ph_chart_template,False +l10n_ph_200300,Output VAT 12% - Actual,200300,liability_current,l10n_ph_chart_template,False +l10n_ph_200301,Deferred Output VAT 12% - Actual,200301,liability_current,l10n_ph_chart_template,False +l10n_ph_200302,Tax Payable-Withholding Tax Compensation,200302,liability_current,l10n_ph_chart_template,False +l10n_ph_200303,Tax Pay-Withholding Tax Source,200303,liability_current,l10n_ph_chart_template,False +l10n_ph_200304,Deferred Tax Pay-Withholding Tax Source,200304,liability_current,l10n_ph_chart_template,False +l10n_ph_200305,Taxes Payable-Final Withholding Tax,200305,liability_current,l10n_ph_chart_template,False +l10n_ph_200306,Tax Payable-Withholding Tax at Source (Accrual),200306,liability_current,l10n_ph_chart_template,False +l10n_ph_200307,Income Tax Payable,200307,liability_current,l10n_ph_chart_template,False +l10n_ph_200308,Accrued Fringe Benefit Tax,200308,liability_current,l10n_ph_chart_template,False +l10n_ph_200400,Other Non-current Liability,200400,liability_non_current,l10n_ph_chart_template,False +l10n_ph_300000,Capital Stock,300000,equity,l10n_ph_chart_template,False +l10n_ph_300001,Additional Paid in Capital,300001,equity,l10n_ph_chart_template,False +l10n_ph_300002,Retained Earnings,300002,equity,l10n_ph_chart_template,False +l10n_ph_430400,Sales/Revenues,430400,income,l10n_ph_chart_template,False +l10n_ph_510000,Cost of Goods Sold,510000,expense_direct_cost,l10n_ph_chart_template,False +l10n_ph_511100,COGS - Purchases,511100,expense_direct_cost,l10n_ph_chart_template,False +l10n_ph_511600,COGS - Freight Costs,511600,expense_direct_cost,l10n_ph_chart_template,False +l10n_ph_511700,COGS - Direct Labor,511700,expense_direct_cost,l10n_ph_chart_template,False +l10n_ph_511800,COGS - Factory/Processing Overhead,511800,expense_direct_cost,l10n_ph_chart_template,False +l10n_ph_620000,Admin Expense,620000,expense,l10n_ph_chart_template,False +l10n_ph_620001,Marketing Expense,620001,expense,l10n_ph_chart_template,False +l10n_ph_620100,Lease-Corporate Offices,620100,expense,l10n_ph_chart_template,False +l10n_ph_621000,Insurance Expenses,621000,expense,l10n_ph_chart_template,False +l10n_ph_622000,Repairs & Maintenance,622000,expense,l10n_ph_chart_template,False +l10n_ph_623000,Salaries & Wages,623000,expense,l10n_ph_chart_template,False +l10n_ph_623001,Overtime Pay,623001,expense,l10n_ph_chart_template,False +l10n_ph_623002,SSS Contribution,623002,expense,l10n_ph_chart_template,False +l10n_ph_623003,HDMF Contribution,623003,expense,l10n_ph_chart_template,False +l10n_ph_623004,PHIC Contribution,623004,expense,l10n_ph_chart_template,False +l10n_ph_623005,Meal Allowance,623005,expense,l10n_ph_chart_template,False +l10n_ph_623006,Other Allowance,623006,expense,l10n_ph_chart_template,False +l10n_ph_623007,13th Month Pay,623007,expense,l10n_ph_chart_template,False +l10n_ph_623008,Retirement Expenses,623008,expense,l10n_ph_chart_template,False +l10n_ph_623009,Training and Webinar,623009,expense,l10n_ph_chart_template,False +l10n_ph_623014,Sick Leave Expenses,623014,expense,l10n_ph_chart_template,False +l10n_ph_623015,Vacation Leave Expenses,623015,expense,l10n_ph_chart_template,False +l10n_ph_624000,Taxes and Licenses,624000,expense,l10n_ph_chart_template,False +l10n_ph_625000,Utilities Expenses,625000,expense,l10n_ph_chart_template,False +l10n_ph_626000,Security Services,626000,expense,l10n_ph_chart_template,False +l10n_ph_626001,Professional Fees,626001,expense,l10n_ph_chart_template,False +l10n_ph_627000,Travel and Transportation,627000,expense,l10n_ph_chart_template,False +l10n_ph_628000,Advertising and Promotion,628000,expense,l10n_ph_chart_template,False +l10n_ph_629000,Depreciation Expense,629000,expense_depreciation,l10n_ph_chart_template,False +l10n_ph_632000,Commission Expense,632000,expense,l10n_ph_chart_template,False +l10n_ph_633000,Supplies Expenses,633000,expense,l10n_ph_chart_template,False +l10n_ph_634000,Miscellaneous Expenses,634000,expense,l10n_ph_chart_template,False +l10n_ph_634001,Bank Fees,634001,expense,l10n_ph_chart_template,False +l10n_ph_635000,Prov DA-Billed Accts,635000,expense,l10n_ph_chart_template,False +l10n_ph_635001,Prov-Probable Expenses,635001,expense,l10n_ph_chart_template,False +l10n_ph_635002,Prov for Inc Tax - Creditable,635002,expense,l10n_ph_chart_template,False +l10n_ph_635003,Provision for Tax - Final,635003,expense,l10n_ph_chart_template,False +l10n_ph_710100,Forex Gain,710100,income_other,l10n_ph_chart_template,False +l10n_ph_710101,Forex Loss,710101,expense,l10n_ph_chart_template,False +l10n_ph_710102,Cash Difference Gain,710102,income_other,l10n_ph_chart_template,False +l10n_ph_710103,Cash Difference Loss,710103,expense,l10n_ph_chart_template,False +l10n_ph_710200,Gain/Loss- Sale FA,710200,expense,l10n_ph_chart_template,False +l10n_ph_710201,Loss on FA Disposal,710201,expense,l10n_ph_chart_template,False +l10n_ph_710300,Interest Inc-Savings,710300,income_other,l10n_ph_chart_template,False +l10n_ph_710301,Interest Income-Savings Local,710301,income_other,l10n_ph_chart_template,False +l10n_ph_710400,Other Income,710400,income_other,l10n_ph_chart_template,False +l10n_ph_710500,Interest Expense-Suppliers' Credit Local,710500,income_other,l10n_ph_chart_template,False +l10n_ph_999999,Undistributed Profits/Losses,999999,equity_unaffected,l10n_ph_chart_template,False diff --git a/addons/l10n_ph/data/account_chart_template_configure_data.xml b/addons/l10n_ph/data/account_chart_template_configure_data.xml new file mode 100644 index 00000000000..d2cfa0f84b8 --- /dev/null +++ b/addons/l10n_ph/data/account_chart_template_configure_data.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/addons/l10n_ph/data/account_chart_template_data.xml b/addons/l10n_ph/data/account_chart_template_data.xml new file mode 100644 index 00000000000..b3748c0c31f --- /dev/null +++ b/addons/l10n_ph/data/account_chart_template_data.xml @@ -0,0 +1,13 @@ + + + + Philippines Account Template + 1000 + 1001 + 1002 + 6 + + + + + diff --git a/addons/l10n_ph/data/account_chart_template_post_data.xml b/addons/l10n_ph/data/account_chart_template_post_data.xml new file mode 100644 index 00000000000..87e71caed57 --- /dev/null +++ b/addons/l10n_ph/data/account_chart_template_post_data.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/addons/l10n_ph/data/account_fiscal_position_tax_template.xml b/addons/l10n_ph/data/account_fiscal_position_tax_template.xml new file mode 100644 index 00000000000..92ba64293e6 --- /dev/null +++ b/addons/l10n_ph/data/account_fiscal_position_tax_template.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/addons/l10n_ph/data/account_fiscal_position_template.xml b/addons/l10n_ph/data/account_fiscal_position_template.xml new file mode 100644 index 00000000000..af60c16b6d6 --- /dev/null +++ b/addons/l10n_ph/data/account_fiscal_position_template.xml @@ -0,0 +1,18 @@ + + + + 1 + VAT Registered + + + + + + + 2 + VAT Exempt + + + + + diff --git a/addons/l10n_ph/data/account_tax_group.xml b/addons/l10n_ph/data/account_tax_group.xml new file mode 100644 index 00000000000..f0590a88ade --- /dev/null +++ b/addons/l10n_ph/data/account_tax_group.xml @@ -0,0 +1,27 @@ + + + + VAT 12% + + + VAT Exempt + + + WHT 0.5% + + + WHT 1% + + + WHT 2% + + + WHT 5% + + + WHT 10% + + + WHT 15% + + diff --git a/addons/l10n_ph/data/account_tax_template.xml b/addons/l10n_ph/data/account_tax_template.xml new file mode 100644 index 00000000000..3f8b9cc54a9 --- /dev/null +++ b/addons/l10n_ph/data/account_tax_template.xml @@ -0,0 +1,1049 @@ + + + + 10 + + 12% VAT + 12% VAT + sale + 12 + percent + + + + + + 10 + + VAT Exempt + VAT Exempt + sale + 0 + percent + + + + + + 20 + + 12% VAT + 12% VAT + purchase + 12 + percent + + + + + + 20 + + VAT Exempt + VAT Exempt + purchase + 0 + percent + + + + + + 30 + + 5% WI010 - Prof Fees + Prof Fees + WI010 + purchase + -5 + percent + + + + + + 30 + + 10% WI011 - Prof Fees + Prof Fees + WI011 + purchase + -10 + percent + + + + + + 40 + + 5% WI100 - Gross rental of property + Gross rental of property + WI100 + purchase + -5 + percent + + + + + + 50 + + 2% WI120 - Contractors + Contractors + WI120 + purchase + -2 + percent + + + + + + 60 + + 5% WI139 - Commission of service fees + Commission of service fees + WI139 + purchase + -5 + percent + + + + + + 60 + + 10% WI140 - Commission of service fees + Commission of service fees + WI140 + purchase + -10 + percent + + + + + + 70 + + 0.5% WI158 - Credit card companies + Credit card companies + WI158 + purchase + -0.5 + percent + + + + + + 80 + + 1% WI640 - Supplier of goods + Supplier of goods + WI640 + purchase + -1 + percent + + + + + + 80 + + 2% WI157 - Supplier of services + Supplier of services + WI157 + purchase + -2 + percent + + + + + + 90 + + 1% WI158 - Supplier of goods by top w/holding agents + Supplier of goods by top w/holding agents + WI158 + purchase + -1 + percent + + + + + + 90 + + 2% WI160 - Supplier of goods by top w/holding agents + Supplier of goods by top w/holding agents + WI160 + purchase + -2 + percent + + + + + + 100 + + 5% WI515 - Commission, rebates, discounts + Commission, rebates, discounts + WI515 + purchase + -5 + percent + + + + + + 100 + + 10% WI516 - Commission, rebates, discounts + Commission, rebates, discounts + WI516 + purchase + -10 + percent + + + + + + 110 + + 10% WC010 - Prof Fees + Prof Fees + WC010 + purchase + -10 + percent + + + + + + 110 + + 15% WC011 - Prof Fees + Prof Fees + WC011 + purchase + -15 + percent + + + + + + 120 + + 5% WC100 - Gross rental of property + Gross rental of property + WC100 + purchase + -5 + percent + + + + + + 130 + + 2% WC120 - Contractors + Contractors + WC120 + purchase + -2 + percent + + + + + + 140 + + 10% WC139 - Commission of service fees + Commission of service fees + WC139 + purchase + -10 + percent + + + + + + 140 + + 15% WC140 - Commission of service fees + Commission of service fees + WC140 + purchase + -15 + percent + + + + + + 150 + + 0.5% WC158 - Credit card companies + Credit card companies + WC158 + purchase + -0.5 + percent + + + + + + 160 + + 1% WC640 - Supplier of goods + Supplier of goods + WC640 + purchase + -1 + percent + + + + + + 160 + + 2% WC157 - Supplier of services + Supplier of services + WC157 + purchase + -2 + percent + + + + + + 170 + + 1% WC158 - Supplier of goods by top w/holding agents + Supplier of goods by top w/holding agents + WC158 + purchase + -1 + percent + + + + + + 170 + + 2% WC160 - Supplier of goods by top w/holding agents + Supplier of goods by top w/holding agents + WC160 + purchase + -2 + percent + + + + + + 180 + + 5% WC515 - Commission, rebates, discounts + Commission, rebates, discounts + WC515 + purchase + -5 + percent + + + + + + 180 + + 10% WC516 - Commission, rebates, discounts + Commission, rebates, discounts + WC516 + purchase + -10 + percent + + + + + diff --git a/addons/l10n_ph/models/__init__.py b/addons/l10n_ph/models/__init__.py new file mode 100644 index 00000000000..e32724d8bb3 --- /dev/null +++ b/addons/l10n_ph/models/__init__.py @@ -0,0 +1,7 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import res_partner +from . import account_move +from . import account_payment +from . import account_tax +from . import account_tax_template diff --git a/addons/l10n_ph/models/account_move.py b/addons/l10n_ph/models/account_move.py new file mode 100644 index 00000000000..4a435f738f4 --- /dev/null +++ b/addons/l10n_ph/models/account_move.py @@ -0,0 +1,19 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import _, models +from odoo.exceptions import UserError + + +class AccountMove(models.Model): + _inherit = "account.move" + + def action_open_l10n_ph_2307_wizard(self): + vendor_bills = self.filtered_domain([('move_type', '=', 'in_invoice')]) + if vendor_bills: + wizard_action = self.env["ir.actions.act_window"]._for_xml_id("l10n_ph.view_l10n_ph_2307_wizard_act_window") + wizard_action.update({ + 'context': {'default_moves_to_export': vendor_bills.ids} + }) + return wizard_action + else: + raise UserError(_('Only Vendor Bills are available.')) diff --git a/addons/l10n_ph/models/account_payment.py b/addons/l10n_ph/models/account_payment.py new file mode 100644 index 00000000000..7af7c268b53 --- /dev/null +++ b/addons/l10n_ph/models/account_payment.py @@ -0,0 +1,19 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import _, models +from odoo.exceptions import UserError + + +class AccountPayment(models.Model): + _inherit = "account.payment" + + def action_open_l10n_ph_2307_wizard(self): + self.ensure_one() + if self.payment_type == 'outbound': + wizard_action = self.env["ir.actions.act_window"]._for_xml_id("l10n_ph.view_l10n_ph_2307_wizard_act_window") + wizard_action.update({ + 'context': {'default_moves_to_export': self.reconciled_bill_ids.ids} + }) + return wizard_action + else: + raise UserError(_('Only Outbound Payment is available.')) diff --git a/addons/l10n_ph/models/account_tax.py b/addons/l10n_ph/models/account_tax.py new file mode 100644 index 00000000000..cfe382a1af6 --- /dev/null +++ b/addons/l10n_ph/models/account_tax.py @@ -0,0 +1,9 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models + + +class AccountTax(models.Model): + _inherit = "account.tax" + + l10n_ph_atc = fields.Char("Philippines ATC") diff --git a/addons/l10n_ph/models/account_tax_template.py b/addons/l10n_ph/models/account_tax_template.py new file mode 100644 index 00000000000..f1334ae021e --- /dev/null +++ b/addons/l10n_ph/models/account_tax_template.py @@ -0,0 +1,14 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models + + +class AccountTaxTemplate(models.Model): + _inherit = "account.tax.template" + + l10n_ph_atc = fields.Char("Philippines ATC") + + def _get_tax_vals(self, company, tax_template_to_tax): + val = super()._get_tax_vals(company, tax_template_to_tax) + val.update({"l10n_ph_atc": self.l10n_ph_atc}) + return val diff --git a/addons/l10n_ph/models/res_partner.py b/addons/l10n_ph/models/res_partner.py new file mode 100644 index 00000000000..d994711f0c8 --- /dev/null +++ b/addons/l10n_ph/models/res_partner.py @@ -0,0 +1,22 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import re + +from odoo import fields, api, models + +CHECK_VAT_PH_RE = re.compile(r"\d{3}-\d{3}-\d{3}-\d{5}") + +class ResPartner(models.Model): + _inherit = "res.partner" + + branch_code = fields.Char("Branch Code", default='000', required=True) + first_name = fields.Char("First Name") + middle_name = fields.Char("Middle Name") + last_name = fields.Char("Last Name") + + @api.model + def _commercial_fields(self): + return super()._commercial_fields() + ['branch_code'] + + def check_vat_ph(self, vat): + return len(vat) == 17 and CHECK_VAT_PH_RE.match(vat) diff --git a/addons/l10n_ph/security/ir.model.access.csv b/addons/l10n_ph/security/ir.model.access.csv new file mode 100644 index 00000000000..3f1e3cafb40 --- /dev/null +++ b/addons/l10n_ph/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +generate_2307_wizard,access_generate_2307_wizard,model_l10n_ph_2307_wizard,account.group_account_invoice,1,1,1,1 diff --git a/addons/l10n_ph/views/account_move_views.xml b/addons/l10n_ph/views/account_move_views.xml new file mode 100644 index 00000000000..94a4ad596fa --- /dev/null +++ b/addons/l10n_ph/views/account_move_views.xml @@ -0,0 +1,12 @@ + + + + Download BIR 2307 XLS + + + + list,form + code + action = records.action_open_l10n_ph_2307_wizard() + + diff --git a/addons/l10n_ph/views/account_payment_views.xml b/addons/l10n_ph/views/account_payment_views.xml new file mode 100644 index 00000000000..b050ea7ec22 --- /dev/null +++ b/addons/l10n_ph/views/account_payment_views.xml @@ -0,0 +1,12 @@ + + + + Download BIR 2307 XLS + + + + form + code + action = record.action_open_l10n_ph_2307_wizard() + + diff --git a/addons/l10n_ph/views/account_tax_views.xml b/addons/l10n_ph/views/account_tax_views.xml new file mode 100644 index 00000000000..7d35d3f8d21 --- /dev/null +++ b/addons/l10n_ph/views/account_tax_views.xml @@ -0,0 +1,19 @@ + + + + account.tax.view.form.inherit.l10n_ph + account.tax + + + + + + + + + + + + + + diff --git a/addons/l10n_ph/views/res_partner_views.xml b/addons/l10n_ph/views/res_partner_views.xml new file mode 100644 index 00000000000..9979409e5d0 --- /dev/null +++ b/addons/l10n_ph/views/res_partner_views.xml @@ -0,0 +1,16 @@ + + + + res.partner.form.inherit.l10n_ph_bir + res.partner + + + + + + + + + + + diff --git a/addons/l10n_ph/wizard/__init__.py b/addons/l10n_ph/wizard/__init__.py new file mode 100644 index 00000000000..ac9c12820f8 --- /dev/null +++ b/addons/l10n_ph/wizard/__init__.py @@ -0,0 +1,3 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import generate_2307_wizard diff --git a/addons/l10n_ph/wizard/generate_2307_wizard.py b/addons/l10n_ph/wizard/generate_2307_wizard.py new file mode 100644 index 00000000000..f76e97e4200 --- /dev/null +++ b/addons/l10n_ph/wizard/generate_2307_wizard.py @@ -0,0 +1,93 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import base64 +import io +import re +import xlwt + +from odoo import fields, models +from odoo.tools.misc import format_date + + +COLUMN_HEADER_MAP = { + "Reporting_Month": "invoice_date", + "Vendor_TIN": "vat", + "branchCode": "branch_code", + "companyName": "company_name", + "surName": "last_name", + "firstName": "first_name", + "middleName": "middle_name", + "address": "address", + "nature": "product_name", + "ATC": "atc", + "income_payment": "price_subtotal", + "ewt_rate": "amount", + "tax_amount": "tax_amount", +} + +class Generate2307Wizard(models.TransientModel): + _name = "l10n_ph_2307.wizard" + _description = "Exports 2307 data to a XLS file." + + moves_to_export = fields.Many2many("account.move", string="Joural To Include") + generate_xls_file = fields.Binary( + "Generated file", + help="Technical field used to temporarily hold the generated XLS file before its downloaded." + ) + + def _write_single_row(self, worksheet, worksheet_row, values): + for index, field in enumerate(COLUMN_HEADER_MAP.values()): + worksheet.write(worksheet_row, index, label=values[field]) + + def _write_rows(self, worksheet, moves): + worksheet_row = 0 + for move in moves: + worksheet_row += 1 + partner = move.partner_id + partner_address_info = [partner.street, partner.street2, partner.city, partner.state_id.name, partner.country_id.name] + values = { + 'invoice_date': format_date(self.env, move.invoice_date, date_format="MM/dd/yyyy"), + 'vat': re.sub(r'\-', '', partner.vat)[:9] if partner.vat else '', + 'branch_code': partner.branch_code or '000', + 'company_name': partner.commercial_partner_id.name, + 'first_name': partner.first_name or '', + 'middle_name': partner.middle_name or '', + 'last_name': partner.last_name or '', + 'address': ', '.join([val for val in partner_address_info if val]) + } + for invoice_line in move.invoice_line_ids.filtered(lambda l: not l.display_type): + for tax in invoice_line.tax_ids.filtered(lambda x: x.l10n_ph_atc): + values['product_name'] = re.sub(r'[\(\)]', '', invoice_line.product_id.name) + values['atc'] = tax.l10n_ph_atc + values['price_subtotal'] = invoice_line.price_subtotal + values['amount'] = tax.amount + values['tax_amount'] = tax._compute_amount(invoice_line.price_subtotal, invoice_line.price_unit) + self._write_single_row(worksheet, worksheet_row, values) + worksheet_row += 1 + + def action_generate(self): + """ Generate a xls format file for importing to + https://bir-excel-uploader.com/excel-file-to-bir-dat-format/#bir-form-2307-settings. + This website will then generate a BIR 2307 format excel file for uploading to the + PH government. + """ + self.ensure_one() + + file_data = io.BytesIO() + workbook = xlwt.Workbook(encoding='utf-8') + worksheet = workbook.add_sheet('Form2307') + + for index, col_header in enumerate(COLUMN_HEADER_MAP.keys()): + worksheet.write(0, index, label=col_header) + + self._write_rows(worksheet, self.moves_to_export) + + workbook.save(file_data) + file_data.seek(0) + self.generate_xls_file = base64.b64encode(file_data.read()) + + return { + "type": "ir.actions.act_url", + "target": "self", + "url": "/web/content?model=l10n_ph_2307.wizard&download=true&field=generate_xls_file&filename=Form_2307.xls&id={}".format(self.id), + } diff --git a/addons/l10n_ph/wizard/generate_2307_wizard_views.xml b/addons/l10n_ph/wizard/generate_2307_wizard_views.xml new file mode 100644 index 00000000000..a0a11c65920 --- /dev/null +++ b/addons/l10n_ph/wizard/generate_2307_wizard_views.xml @@ -0,0 +1,36 @@ + + + + l10n_ph_2307.wizard.form + l10n_ph_2307.wizard + +
+ This will export a XLS file for BIR 2307. + + + + + + + + + + + + + + +
+
+
+
+
+ + BIR 2307 Report + l10n_ph_2307.wizard + form + new + +