Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.0 accrue income 1 #221

Merged
merged 3 commits into from
Aug 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hr_timesheet_accrue_income/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Generate Accrue Income Based On Timesheet Details",
"version": "8.0.1.0.0",
"version": "8.0.1.1.0",
"website": "https://simetri-sinergi.id",
"author": "PT. Simetri Sinergi Indonesia, OpenSynergy Indonesia",
"license": "AGPL-3",
Expand Down
7 changes: 7 additions & 0 deletions hr_timesheet_accrue_income/models/account_analytic_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ class AccountAnalyticAccount(models.Model):
("type", "=", "other"),
],
)
income_account_id = fields.Many2one(
string="Income Account",
comodel_name="account.account",
domain=[
("type", "=", "other"),
],
)
accrue_income_ok = fields.Boolean(
string="Can Create Accrue Income",
default=False,
Expand Down
31 changes: 28 additions & 3 deletions hr_timesheet_accrue_income/models/hr_analytic_timesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ class HrAnalyticTimesheet(models.Model):
("type", "=", "other"),
],
)
income_account_id = fields.Many2one(
string="Income Account",
comodel_name="account.account",
domain=[
("type", "=", "other"),
],
)
accrue_income_ok = fields.Boolean(
string="Can Create Accrue Income",
default=False,
Expand Down Expand Up @@ -72,6 +79,26 @@ def onchange_accrue_income_account_id(self):

self.accrue_income_account_id = account

@api.onchange(
"account_id",
"product_id",
)
def onchange_income_account_id(self):
account = False
if not account and \
self.account_id and \
self.account_id.accrue_income_account_id:
account = self.account_id.income_account_id

if not account:
account = self.product_id.property_account_income

if not account:
account = \
self.product_id.categ_id.property_account_income_categ

self.income_account_id = account

@api.onchange(
"account_id",
)
Expand Down Expand Up @@ -130,9 +157,7 @@ def _get_accrue_income_account(self):
@api.multi
def _get_income_account(self):
self.ensure_one()
result = self.product_id.categ_id.property_account_income_categ
if not result:
result = self.product_id.property_income_account
result = self.income_account_id
if not result:
err_msg = _("No income account defined")
raise UserError(err_msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<group name="accrue_expense_1" colspan="4" col="2">
<field name="accrue_income_journal_id"/>
<field name="accrue_income_account_id"/>
<field name="income_account_id"/>
<field name="accrue_income_ok"/>
</group>
</page>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<xpath expr="//field[@name='general_account_id']" position="after">
<field name="accrue_income_journal_id"/>
<field name="accrue_income_account_id"/>
<field name="income_account_id"/>
<field name="accrue_income_ok"/>
<field name="accrue_income_move_id"/>
<button name="action_create_accrue_income_move" string="Generate Accrue Income" icon="gtk-apply" type="object" attrs="{'invisible':['|',('accrue_income_move_id','!=',False),('accrue_income_ok','=',False)]}"/>
Expand Down
2 changes: 1 addition & 1 deletion hr_timesheet_sheet_accrue_income/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Generate Accrue Income Based On Timesheet Details - Sheet",
"version": "8.0.1.0.0",
"version": "8.0.1.1.0",
"website": "https://simetri-sinergi.id",
"author": "PT. Simetri Sinergi Indonesia, OpenSynergy Indonesia",
"license": "AGPL-3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<xpath expr="//field[@name='timesheet_ids']/tree/field[@name='product_id']" position="after">
<field name="accrue_income_journal_id" invisible="1"/>
<field name="accrue_income_account_id" invisible="1"/>
<field name="income_account_id" invisible="1"/>
<field name="accrue_income_ok" invisible="1"/>
<field name="accrue_income_move_id" invisible="1"/>
</xpath>
Expand Down
2 changes: 1 addition & 1 deletion hr_timesheet_task_accrue_income/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Generate Accrue Income Based On Task Timesheet",
"version": "8.0.1.0.0",
"version": "8.0.1.1.0",
"website": "https://simetri-sinergi.id",
"author": "PT. Simetri Sinergi Indonesia, OpenSynergy Indonesia",
"license": "AGPL-3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<xpath expr="//field[@name='work_ids']/tree/field[@name='product_id']" position="before">
<field name="accrue_income_journal_id" invisible="1"/>
<field name="accrue_income_account_id" invisible="1"/>
<field name="income_account_id" invisible="1"/>
<field name="accrue_income_ok" invisible="1"/>
<field name="accrue_income_move_id" invisible="1"/>
</xpath>
Expand Down