forked from OCA/contract
-
Notifications
You must be signed in to change notification settings - Fork 0
[WIP][16.0] contract_timesheet #2
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
Draft
mileo
wants to merge
5
commits into
acsone:16.0-contract_timesheet
Choose a base branch
from
kmee:16.0-contract_timesheet
base: 16.0-contract_timesheet
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f46aa29
[IMP] Contract Line name get
mileo 9ad3676
[IMP] Open Projects related to contracts
mileo ba97deb
[NEW] contract on tasks
mileo d64fc59
[REF] contract line on timesheets
mileo 144b852
[WIP] contract on project sale line employee map
mileo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| from . import account_analytic_line | ||
| from . import project_project | ||
| from . import project_sale_line_employee_map | ||
| from . import contract_contract | ||
| from . import project_task |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
contract_timesheet_invoice_type/models/contract_contract.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Copyright 2024 KMEE | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo import _, api, fields, models | ||
|
|
||
|
|
||
| class ContractContract(models.Model): | ||
|
|
||
| _inherit = "contract.contract" | ||
|
|
||
| project_ids = fields.One2many( | ||
| 'project.project', | ||
| 'contract_id', | ||
| ) | ||
|
|
||
| project_count = fields.Integer(compute="_compute_project_count") | ||
|
|
||
| @api.depends("project_ids") | ||
| def _compute_project_count(self): | ||
| for rec in self: | ||
| rec.project_count = len(rec.project_ids) | ||
|
|
||
| def action_view_projects(self): | ||
| self.ensure_one() | ||
| projects = self.project_ids | ||
| action = { | ||
| "name": _("Projects"), | ||
| "view_mode": "tree,form", | ||
| "res_model": "project.project", | ||
| "type": "ir.actions.act_window", | ||
| "domain": [("id", "in", projects.ids)], | ||
| } | ||
| if len(projects) == 1: | ||
| # If there is only one order, open it directly | ||
| action.update({"view_mode": "form", "res_id": projects.id}) | ||
| return action |
29 changes: 29 additions & 0 deletions
29
contract_timesheet_invoice_type/models/project_sale_line_employee_map.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Copyright 2024 KMEE | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo import _, api, fields, models | ||
|
|
||
|
|
||
| class ProjectSaleLineEmployeeMap(models.Model): | ||
|
|
||
| _inherit = "project.sale.line.employee.map" | ||
|
|
||
| contract_line_id = fields.Many2one( | ||
| "contract.line", | ||
| "Contract Item", | ||
| copy=False, | ||
| index="btree_not_null", | ||
| # domain=( | ||
| # "[('partner_id', '=?', partner_id), " | ||
| # "'|', ('company_id', '=', False), ('company_id', '=', company_id)]" | ||
| # ), | ||
| help=( | ||
| "Recurring invoicing contract item that will be used to " | ||
| "determine the timesheet invoicing type." | ||
| ), | ||
| ) | ||
| contract_id = fields.Many2one( | ||
| related="contract_line_id.contract_id", | ||
| readonly=True, | ||
| help="Recurring invoicing contract", | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Copyright 2024 KMEE | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo import _, api, fields, models | ||
|
|
||
|
|
||
| class ProjectTask(models.Model): | ||
|
|
||
| _inherit = "project.task" | ||
|
|
||
| contract_line_id = fields.Many2one( | ||
| "contract.line", | ||
| "Contract Item", | ||
| copy=False, | ||
| # index="btree_not_null", | ||
| domain=( | ||
| "[('partner_id', '=?', partner_id), " | ||
| "'|', ('company_id', '=', False), ('company_id', '=', company_id)]" | ||
| ), | ||
| help=( | ||
| "Recurring invoicing contract item that will be used to " | ||
| "determine the timesheet invoicing type." | ||
| ), | ||
| ) | ||
| contract_id = fields.Many2one( | ||
| related="contract_line_id.contract_id", | ||
| readonly=True, | ||
| help="Recurring invoicing contract", | ||
| ) |
30 changes: 30 additions & 0 deletions
30
contract_timesheet_invoice_type/views/contract_contract.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- Copyright 2024 KMEE | ||
| License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
|
|
||
| <odoo> | ||
|
|
||
| <record id="contract_project_form_view" model="ir.ui.view"> | ||
| <field name="model">contract.contract</field> | ||
| <field name="inherit_id" ref="contract.contract_contract_customer_form_view" /> | ||
| <field name="arch" type="xml"> | ||
| <xpath expr="//div[@name='button_box']" position="inside"> | ||
| <button | ||
| class="oe_stat_button" | ||
| name="action_view_projects" | ||
| type="object" | ||
| icon="fa-edit" | ||
| attrs="{'invisible': [('project_count', '=', 0)]}" | ||
| > | ||
| <div class="o_field_widget o_stat_info"> | ||
| <span class="o_stat_value"> | ||
| <field name="project_count" /> | ||
| </span> | ||
| <span class="o_stat_text">Projects</span> | ||
| </div> | ||
| </button> | ||
| </xpath> | ||
| </field> | ||
| </record> | ||
|
|
||
| </odoo> |
18 changes: 18 additions & 0 deletions
18
contract_timesheet_invoice_type/views/project_sale_line_employee_map.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- Copyright 2024 KMEE | ||
| License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
|
|
||
| <odoo> | ||
|
|
||
| <record model="ir.ui.view" id="project_sale_line_employee_map_form_view"> | ||
| <field name="model">project.project</field> | ||
| <field name="inherit_id" ref="sale_timesheet.project_project_view_form"/> | ||
| <field name="arch" type="xml"> | ||
| <xpath expr="//tree/field[@name='sale_line_id']" position="before"> | ||
| <field name="contract_id" optional="hide"/> | ||
| <field name="contract_line_id" optional="hide"/> | ||
| </xpath> | ||
| </field> | ||
| </record> | ||
|
|
||
| </odoo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- Copyright 2024 KMEE | ||
| License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
|
|
||
| <odoo> | ||
|
|
||
| <record model="ir.ui.view" id="project_task_form_view"> | ||
| <field name="model">project.task</field> | ||
| <field name="inherit_id" ref="project.view_task_form2"/> | ||
| <field name="arch" type="xml"> | ||
| <xpath expr="//field[@name='partner_phone']" position="after"> | ||
| <field name="contract_id" attrs="{'invisible': True}" groups="sales_team.group_sale_salesman"/> | ||
| <field name="contract_line_id" groups="sales_team.group_sale_salesman"/> | ||
| </xpath> | ||
| <xpath expr="//field[@name='timesheet_ids']/tree/field[@name='unit_amount']" position="before"> | ||
| <!-- <field name="timesheet_ids"/> is already inside a block groups="hr_timesheet.group_hr_timesheet_user" --> | ||
| <field name="contract_line_id" /> | ||
| </xpath> | ||
| </field> | ||
| </record> | ||
|
|
||
| </odoo> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.