Skip to content

Commit

Permalink
[ADD] fleet_vehicle_purchase
Browse files Browse the repository at this point in the history
  • Loading branch information
etobella committed Nov 23, 2023
1 parent be9d740 commit ea4c067
Show file tree
Hide file tree
Showing 16 changed files with 684 additions and 0 deletions.
60 changes: 60 additions & 0 deletions fleet_vehicle_purchase/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
======================
Fleet Vehicle Purchase
======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:05acad389aa61f332e9110e3211c532f4da708078ec72a1f63d4747fc3ffae13
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-oxigensalud%2Fodoo--community--addons-lightgray.png?logo=github
:target: https://github.com/oxigensalud/odoo-community-addons/tree/14.0/fleet_vehicle_purchase
:alt: oxigensalud/odoo-community-addons

|badge1| |badge2| |badge3|

Allow to define fleet vehicles on Purchase Orders in order to inherit them properly

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/oxigensalud/odoo-community-addons/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/oxigensalud/odoo-community-addons/issues/new?body=module:%20fleet_vehicle_purchase%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Dixmit

Contributors
~~~~~~~~~~~~

* Enric Tobella - Dixmit

Maintainers
~~~~~~~~~~~

This module is part of the `oxigensalud/odoo-community-addons <https://github.com/oxigensalud/odoo-community-addons/tree/14.0/fleet_vehicle_purchase>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions fleet_vehicle_purchase/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions fleet_vehicle_purchase/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Fleet Vehicle Purchase",
"summary": """
Allow to integrate Purcase with Fleet Vehicles""",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Dixmit,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/fleet",
"depends": [
"account_fleet",
"purchase",
],
"data": [
"views/fleet_vehicle.xml",
"views/purchase_order.xml",
],
"demo": [],
}
2 changes: 2 additions & 0 deletions fleet_vehicle_purchase/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import purchase_order
from . import fleet_vehicle
31 changes: 31 additions & 0 deletions fleet_vehicle_purchase/models/fleet_vehicle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2023 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class FleetVehicle(models.Model):

_inherit = "fleet.vehicle"

purchase_order_ids = fields.One2many(
"purchase.order", inverse_name="fleet_vehicle_id"
)
purchase_order_count = fields.Integer(compute="_compute_purchase_order_count")

@api.depends("purchase_order_ids")
def _compute_purchase_order_count(self):
for record in self:
record.purchase_order_count = len(record.purchase_order_ids)

def action_view_purchase_orders(self):
self.ensure_one()
result = self.env["ir.actions.act_window"]._for_xml_id(
"purchase.purchase_form_action"
)
result.update(
{
"domain": [("fleet_vehicle_id", "=", self.id)],
}
)
return result
21 changes: 21 additions & 0 deletions fleet_vehicle_purchase/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class PurchaseOrder(models.Model):

_inherit = "purchase.order"

fleet_vehicle_id = fields.Many2one("fleet.vehicle", string="Vehicle")


class PurchaseOrderLine(models.Model):

_inherit = "purchase.order.line"

def _prepare_account_move_line(self):
result = super()._prepare_account_move_line()
result["vehicle_id"] = self.order_id.fleet_vehicle_id.id
return result
1 change: 1 addition & 0 deletions fleet_vehicle_purchase/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Enric Tobella - Dixmit
1 change: 1 addition & 0 deletions fleet_vehicle_purchase/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow to define fleet vehicles on Purchase Orders in order to inherit them properly
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ea4c067

Please sign in to comment.