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

[ADD][17.0] tms_expense #133

Open
wants to merge 6 commits into
base: 17.0
Choose a base branch
from
Open

Conversation

EdgarRetes
Copy link

No description provided.

@EdgarRetes
Copy link
Author

@max3903, please check this

@douglascstd
Copy link
Member

[FUNCTIONAL REVIEW]

Problem 1:
I attempted to split an expense that I started to insert into a trip:
image

UncaughtPromiseError > OwlError
Uncaught Promise > The following error occurred in onWillStart: ""hr.expense.split.wizard"."state" field is undefined."

This error does not occur when trying to split an expense started from the "My Expense" menu:
image

Situation 1: Possibility to create a new trip from an expense:
image
It is not possible to link to an existing trip. In my example, I created an expense (Fuel) and split it into several trips.

Situation 2: Filter expenses to know if there is a trip vinculated.
image
Sugestion is insert a field in the hr.expense form:
image

<xpath expr="//field[@name='product_id']" position="after">
  <field name="trip_id" string="Trip"/>
</xpath>

class HrEmployee(models.Model):
_inherit = "hr.employee"

is_driver = fields.Boolean()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This data can be obtained from the partner associated with the employee.

class ResPartner(models.Model):
_inherit = "res.partner"

employee_id = fields.Many2one("hr.employee")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, I also believe that there is no need to create a new field. You can probably retrieve this based on the existing data.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe search for the partner in employee_id.address_home_id (where address_home is a res.partner) or, if it is a user, get the employee_id and partner_id linked to the user.

@@ -22,7 +22,9 @@ class TMSOrder(models.Model):
@api.depends("driver_id")
def _compute_driver_employee_id(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    employee_id = fields.Many2one('hr.employee', string='Driver', compute='_compute_employee_id', store=True)

    @api.depends('driver_id')
    def _compute_employee_id(self):
        for record in self:
            record.employee_id = self.env['hr.employee'].search([('user_partner_id', '=', record.driver_id.id)], limit=1)
            if not record.employee_id:
                record.employee_id = self.env['hr.employee'].search([('address_home_id', '=', record.driver_id.id)], limit=1)

@EdgarRetes EdgarRetes force-pushed the 17.0_tms_expenses branch 2 times, most recently from cb80981 to e14055f Compare August 16, 2024 22:51
@max3903 max3903 added this to the 17.0 milestone Aug 16, 2024
@max3903 max3903 self-assigned this Aug 16, 2024
@max3903 max3903 changed the title [ADD] [17.0] tms expenses [ADD][17.0] tms expenses Oct 8, 2024
@max3903 max3903 mentioned this pull request Oct 10, 2024
3 tasks
@max3903 max3903 changed the title [ADD][17.0] tms expenses [ADD][17.0] tms_expense Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants