Skip to content

Commit

Permalink
[IMP] l10n_us_form_1099
Browse files Browse the repository at this point in the history
  • Loading branch information
Chanakya-SerpentCS authored and BernatPForgeFlow committed Dec 19, 2023
1 parent 95a0a0c commit 5476b98
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 15 deletions.
5 changes: 4 additions & 1 deletion l10n_us_form_1099/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ US Form 1099
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ca6a09d2598e43a884c78485b3203770db77c90a15fd2792e0d6bba822a17dee
!! source digest: sha256:63e8300314753a2a1d05a92c6d6f9dc6e9e1fe5b0bd3905a63a93ddcfb703d06
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
Expand Down Expand Up @@ -66,7 +66,9 @@ To use this module, you need to:
#. If their type is 1099-MISC, you can select their box
#. Go to Invoicing > Bills > Vendors
#. Create vendor bills and payments for those 1099 vendors
#. Modify "Is a 1099" box on Bill Lines based on your need
#. Go to Invoicing > Reporting > 1099 Report
#. If Bill is fully paid then payments will be included in Report

Bug Tracker
===========
Expand Down Expand Up @@ -97,6 +99,7 @@ Contributors
* Brian McMaster <[email protected]>
* Jevin Dement <[email protected]>
* Levent Karakas <[email protected]>
* Chankya Soni <[email protected]>

Other credits
~~~~~~~~~~~~~
Expand Down
3 changes: 2 additions & 1 deletion l10n_us_form_1099/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
"category": "Customers",
"maintainer": "Open Source Integrators",
"website": "https://github.com/OCA/l10n-usa",
"depends": ["contacts", "account"],
"depends": ["contacts", "account", "l10n_us_partner_legal_number"],
"data": [
"data/type_1099_data.xml",
"data/box_1099_misc_data.xml",
"security/ir.model.access.csv",
"views/type_1099_view.xml",
"views/box_1099_misc_view.xml",
"views/res_partner.xml",
"views/account_move.xml",
"reports/account_payment_1099_report_views.xml",
],
"installable": True,
Expand Down
19 changes: 19 additions & 0 deletions l10n_us_form_1099/migrations/14.0.1.0.2/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2017 Open Source Integrators
# Copyright (C) 2019 Brian McMaster
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.logged_query(
env.cr,
"""
UPDATE account_move_line aml
SET is_1099 = v.is_1099,
type_1099_id = v.type_1099_id,
box_1099_misc_id = v.box_1099_misc_id
FROM res_partner v
WHERE aml.partner_id = v.id
""",
)
2 changes: 1 addition & 1 deletion l10n_us_form_1099/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright (C) 2019 Brian McMaster
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import type_1099, box_1099_misc, res_partner
from . import type_1099, box_1099_misc, res_partner, account_move
63 changes: 63 additions & 0 deletions l10n_us_form_1099/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright (C) 2021 Open Source Integrators
# Copyright (C) 2019 Brian McMaster
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class AccountMove(models.Model):
_inherit = "account.move"

@api.onchange("partner_id")
def _onchange_partner_id(self):
"""If lines are already added and user change the partner then
set 1099 information from the new partner"""
result = super(AccountMove, self)._onchange_partner_id()
self.invoice_line_ids.is_1099 = self.partner_id.is_1099
self.invoice_line_ids.type_1099_id = self.partner_id.type_1099_id.id
self.invoice_line_ids.box_1099_misc_id = self.partner_id.box_1099_misc_id.id
return result


class AccountMoveLine(models.Model):
_inherit = "account.move.line"

is_1099 = fields.Boolean("Is a 1099?", compute="_compute_is_1099", store=True)
type_1099_id = fields.Many2one("type.1099", string="1099 Type")
box_1099_misc_id = fields.Many2one("box.1099.misc", string="1099-MISC Box")
legal_id_number = fields.Char(
related="partner_id.legal_id_number", string="Legal ID"
)

@api.depends("product_id")
def _compute_is_1099(self):
for record in self:
record.is_1099 = (
record.move_id.partner_id.is_1099
and record.product_id.type == "service"
)

@api.model
def default_get(self, default_fields):
# OVERRIDE
# Update is_1099, type_1099_id and box_1099_misc_id from default partner
values = super(AccountMoveLine, self).default_get(default_fields)
if values.get("partner_id"):
partner = self.env["res.partner"].browse(values.get("partner_id"))
values.update(
{
"is_1099": partner.is_1099,
"type_1099_id": partner.type_1099_id.id,
"box_1099_misc_id": partner.box_1099_misc_id.id,
}
)
return values

@api.onchange("is_1099", "type_1099_id")
def onchange_is_1099(self):
if not self.is_1099:
self.type_1099_id = False
self.box_1099_misc_id = False
type_1099_id = self.env.ref("l10n_us_form_1099.1099_type_misc")
if self.type_1099_id != type_1099_id:
self.box_1099_misc_id = False
2 changes: 1 addition & 1 deletion l10n_us_form_1099/models/box_1099_misc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2019 Open Source Integrators
# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models
Expand Down
1 change: 1 addition & 0 deletions l10n_us_form_1099/models/type_1099.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright (C) 2021 Open Source Integrators
# Copyright (C) 2019 Brian McMaster
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Expand Down
1 change: 1 addition & 0 deletions l10n_us_form_1099/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
* Brian McMaster <[email protected]>
* Jevin Dement <[email protected]>
* Levent Karakas <[email protected]>
* Chankya Soni <[email protected]>
2 changes: 2 additions & 0 deletions l10n_us_form_1099/readme/USAGE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ To use this module, you need to:
#. If their type is 1099-MISC, you can select their box
#. Go to Invoicing > Bills > Vendors
#. Create vendor bills and payments for those 1099 vendors
#. Modify "Is a 1099" box on Bill Lines based on your need
#. Go to Invoicing > Reporting > 1099 Report
#. If Bill is fully paid then payments will be included in Report
1 change: 1 addition & 0 deletions l10n_us_form_1099/reports/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright (C) 2021 Open Source Integrators
# Copyright (C) 2019 Brian McMaster
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

Expand Down
25 changes: 15 additions & 10 deletions l10n_us_form_1099/reports/account_payment_1099_report.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (C) 2019 Brian McMaster
# Copyright (C) 2019 Open Source Integrators
# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from psycopg2.extensions import AsIs
Expand All @@ -17,33 +17,38 @@ class AccountPayment1099Report(models.Model):
vendor_id = fields.Many2one("res.partner", "Vendor", readonly=True)
type_1099 = fields.Many2one("type.1099", "1099 Type", readonly=True)
box_1099_misc = fields.Many2one("box.1099.misc", "1099-MISC Box", readonly=True)
legal_id_number = fields.Char("Legal ID", readonly=True)

def _select(self):
return """
SELECT
pmt.id AS id,
am.date AS date,
pmt.amount AS amount,
v.id AS vendor_id,
v.type_1099_id AS type_1099,
v.box_1099_misc_id AS box_1099_misc
aml.id AS id,
am.date AS date,
aml.price_total AS amount,
aml.type_1099_id AS type_1099,
aml.box_1099_misc_id AS box_1099_misc,
v.legal_id_number as legal_id_number
"""

def _from(self):
return """
FROM account_payment AS pmt
FROM account_move_line AS aml
"""

def _join(self):
return """
JOIN res_partner AS v ON pmt.partner_id = v.id
JOIN account_move AS am ON pmt.move_id = am.id
JOIN account_move AS am ON aml.move_id = am.id
JOIN res_partner AS v ON am.partner_id = v.id
"""

def _where(self):
return """
WHERE
v.is_1099 = TRUE
am.payment_state='paid' and
am.move_type='in_invoice' and
aml.exclude_from_invoice_tab=false and
aml.is_1099=True
"""

def init(self):
Expand Down
5 changes: 4 additions & 1 deletion l10n_us_form_1099/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">US Form 1099</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ca6a09d2598e43a884c78485b3203770db77c90a15fd2792e0d6bba822a17dee
!! source digest: sha256:63e8300314753a2a1d05a92c6d6f9dc6e9e1fe5b0bd3905a63a93ddcfb703d06
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-usa/tree/16.0/l10n_us_form_1099"><img alt="OCA/l10n-usa" src="https://img.shields.io/badge/github-OCA%2Fl10n--usa-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-usa-16-0/l10n-usa-16-0-l10n_us_form_1099"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-usa&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>When companies hire others as contractors, the contractor in question may
Expand Down Expand Up @@ -414,7 +414,9 @@ <h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<li>If their type is 1099-MISC, you can select their box</li>
<li>Go to Invoicing &gt; Bills &gt; Vendors</li>
<li>Create vendor bills and payments for those 1099 vendors</li>
<li>Modify “Is a 1099” box on Bill Lines based on your need</li>
<li>Go to Invoicing &gt; Reporting &gt; 1099 Report</li>
<li>If Bill is fully paid then payments will be included in Report</li>
</ol>
</div>
<div class="section" id="bug-tracker">
Expand Down Expand Up @@ -444,6 +446,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Brian McMaster &lt;<a class="reference external" href="mailto:brian&#64;mcmpest.com">brian&#64;mcmpest.com</a>&gt;</li>
<li>Jevin Dement &lt;<a class="reference external" href="mailto:jdement&#64;opensourceintegrators.com">jdement&#64;opensourceintegrators.com</a>&gt;</li>
<li>Levent Karakas &lt;<a class="reference external" href="mailto:leventk&#64;eska.biz">leventk&#64;eska.biz</a>&gt;</li>
<li>Chankya Soni &lt;<a class="reference external" href="mailto:csoni&#64;opensourceintegrators.com">csoni&#64;opensourceintegrators.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
Expand Down
58 changes: 58 additions & 0 deletions l10n_us_form_1099/views/account_move.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<odoo>
<!-- Copyright (C) 2021 Open Source Integrators Copyright (C) 2019 Brian
McMaster License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<record id="account_move_view_form_l10n_us_1099" model="ir.ui.view">
<field name="name">account_move_line_view_form</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<xpath
expr="//field[@name='invoice_line_ids']//field[@name='account_id']"
position="after"
>
<field
name="is_1099"
attrs="{'column_invisible' : [('parent.move_type', '!=', 'in_invoice')]}"
/>
<field
name="type_1099_id"
options="{'no_create': 1, 'no_open':1}"
attrs="{'readonly': [('is_1099', '=', False)], 'column_invisible' : [('parent.move_type', '!=', 'in_invoice')]}"
/>
<field
name="box_1099_misc_id"
options="{'no_create': 1, 'no_open':1}"
attrs="{'readonly': ['|',('is_1099', '=', False),('type_1099_id', '!=', %(l10n_us_form_1099.1099_type_misc)d)],
'column_invisible' : [('parent.move_type', '!=', 'in_invoice')]}"
/>
<field
name="legal_id_number"
attrs="{'column_invisible' : [('parent.move_type', '!=', 'in_invoice')]}"
/>
</xpath>

<xpath
expr="//field[@name='line_ids']//field[@name='account_id']"
position="after"
>
<field name="is_1099" invisible="1" />
<field
name="type_1099_id"
options="{'no_create': 1, 'no_open':1}"
attrs="{'readonly': [('is_1099', '=', False)]}"
invisible="1"
/>
<field
name="box_1099_misc_id"
options="{'no_create': 1, 'no_open':1}"
invisible="1"
attrs="{'readonly': ['|', ('is_1099', '=', False),('type_1099_id', '!=', %(l10n_us_form_1099.1099_type_misc)d)]}"
/>
<field name="legal_id_number" invisible="1" />
</xpath>

</field>
</record>

</odoo>

0 comments on commit 5476b98

Please sign in to comment.