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

12.0 imp joint buying base allow multi carrier in same point #109

Draft
wants to merge 3 commits into
base: 12.0
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions joint_buying_base/demo/joint_buying_carrier.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@
<field name="currency_id" ref="base.EUR"/>
</record>

<record id="carrier_extra_COU" model="joint.buying.carrier">
<field name="name">Extra COU</field>
<field name="is_provider" eval="True"/>
<field name="currency_id" ref="base.EUR"/>
</record>

</odoo>
29 changes: 29 additions & 0 deletions joint_buying_base/demo/joint_buying_tour.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,35 @@
<field name="duration" eval="30/60"/>
</record>

<!-- -->
<!-- Tournée CDA - GOU EXTRA -->
<!-- -->

<record id="tour_cda_gou_1" model="joint.buying.tour">
<field name="name">Lyon - Loire</field>
<field name="type_id" ref="type_extra_COU"/>
<field name="carrier_id" ref="carrier_extra_COU"/>
<field name="start_date" eval="(DateTime.today() + timedelta(days=1)).strftime('%Y-%m-%d 10:30')"/>
</record>

<record id="tour_cda_gou_1_line_1" model="joint.buying.tour.line">
<field name="sequence">1</field>
<field name="sequence_type">handling</field>
<field name="tour_id" ref="tour_cda_gou_1"/>
<field name="duration" eval="2/60"/>
</record>

<record id="tour_cda_gou_1_line_2" model="joint.buying.tour.line">
<field name="sequence">2</field>
<field name="sequence_type">journey</field>
<field name="duration" eval="89/60"/>
<field name="distance">122</field>
<field name="tour_id" ref="tour_cda_gou_1"/>
<field name="starting_point_id" model="res.partner" eval="obj().env.ref('joint_buying_base.company_CDA').joint_buying_partner_id.id"/>
<field name="arrival_point_id" model="res.partner" eval="obj().env.ref('joint_buying_base.company_GOU').joint_buying_partner_id.id"/>
</record>


<!-- -->
<!-- Tournée Lyon - Loire 2 -->
<!-- -->
Expand Down
5 changes: 5 additions & 0 deletions joint_buying_base/demo/joint_buying_tour_type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@
<field name="carrier_id" ref="carrier_coolivri_savoie"/>
</record>

<record id="type_extra_COU" model="joint.buying.tour.type">
<field name="name">Savoie Impaire</field>
<field name="carrier_id" ref="carrier_extra_COU"/>
</record>

</odoo>
13 changes: 13 additions & 0 deletions joint_buying_base/demo/joint_buying_transport_request.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@
]]></field>
</record>

<record id="request_vev_gou_week_1" model="joint.buying.transport.request">
<field name="manual_start_partner_id" model="res.partner" eval="obj().env.ref('joint_buying_base.company_VEV').joint_buying_partner_id.id"/>
<field name="manual_arrival_partner_id" model="res.partner" eval="obj().env.ref('joint_buying_base.company_GOU').joint_buying_partner_id.id"/>
<field name="manual_availability_date" eval="(DateTime.today() + timedelta(days=1)).strftime('%Y-%m-%d 08:40')"/>
<field name="manual_amount_untaxed">1000</field>
<field name="manual_total_weight">200</field>
<field name="manual_description"><![CDATA[
Manual Description : VEV -> GOU
]]></field>
</record>


<record id="request_vev_che_week_2" model="joint.buying.transport.request">
<field name="manual_start_partner_id" model="res.partner" eval="obj().env.ref('joint_buying_base.company_VEV').joint_buying_partner_id.id"/>
<field name="manual_arrival_partner_id" model="res.partner" eval="obj().env.ref('joint_buying_base.company_CHE').joint_buying_partner_id.id"/>
Expand All @@ -74,6 +86,7 @@
ref('joint_buying_base.request_vev_cda_week_1'),
ref('joint_buying_base.request_vev_che_week_1'),
ref('joint_buying_base.request_vev_edc_week_1'),
ref('joint_buying_base.request_vev_gou_week_1'),
ref('joint_buying_base.request_vev_fumet_dombes_week_1'),
ref('joint_buying_base.request_vev_che_week_2'),
]"/>
Expand Down
13 changes: 13 additions & 0 deletions joint_buying_base/demo/res_company.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@
<field name="logo" type="base64" file="joint_buying_base/static/img/company_ELD-logo.png"/>
</record>

<record id="company_GOU" model="res.company">
<field name="code">GOU</field>
<field name="name">[GOU - Taste of Kids]</field>
<field name="email">[email protected]/</field>
<field name="street"> Avenue du 8 Mai</field>
<field name="city">Saint Just La Pendue</field>
<field name="zip">42540</field>
<field name="country_id" ref="base.fr"/>
<field name="partner_latitude">45.8915716</field>
<field name="partner_longitude">4.2352806</field>
<field name="logo" type="base64" file="joint_buying_base/static/img/company_GOU-logo.png"/>
</record>

<record id="company_LSE" model="res.company">
<field name="code">LSE</field>
<field name="name">[LSE - The Super Mall]</field>
Expand Down
1 change: 1 addition & 0 deletions joint_buying_base/demo/res_users.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
(4, ref('joint_buying_base.company_CRB')),
(4, ref('joint_buying_base.company_EDC')),
(4, ref('joint_buying_base.company_ELD')),
(4, ref('joint_buying_base.company_GOU')),
(4, ref('joint_buying_base.company_LSE')),
(4, ref('joint_buying_base.company_LOG')),
(4, ref('joint_buying_base.company_PZI')),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions joint_buying_base/wizards/joint_buying_wizard_find_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ def _populate_tree(self, transport_request):
transport_request.arrival_partner_id,
)

# we've arrived at our destination!
if (
found_line.arrival_point_id
== transport_request.arrival_partner_id
):
return tree
# # we've arrived at our destination!
# if (
# found_line.arrival_point_id
# == transport_request.arrival_partner_id
# ):
# return tree

return tree

Expand All @@ -274,6 +274,8 @@ def _get_interesting_route(self, tour, from_line, destination, excludes):
]

# The destination is present in the available lines, directly return
# Exemple: tour is A -> B -> C -> D -> E and destination is D,
# return D.
if destination in [x.arrival_point_id for x in available_lines]:
return available_lines

Expand Down
26 changes: 23 additions & 3 deletions joint_buying_product/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from datetime import timedelta

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.exceptions import AccessError, ValidationError

from odoo.addons.joint_buying_base.models.res_partner import (
_JOINT_BUYING_PARTNER_CONTEXT,
Expand Down Expand Up @@ -171,8 +171,17 @@ def set_joint_buying_local_product_id(self, new_local_product):
if current_local_product == new_local_product:
# Nothing change
return
if current_local_product:
raise ValidationError(_("Unimplemented Feature"))
if (
current_local_product
and current_local_product.company_id.joint_buying_partner_id
== self.joint_buying_partner_id
):
raise ValidationError(
_(
"You can not change the relation between a global product"
" and a local product if you sale it."
)
)
new_local_product.joint_buying_product_id = self and self.id

@api.model
Expand Down Expand Up @@ -209,10 +218,21 @@ def create_joint_buying_product(self):
def update_joint_buying_product(self):
products = self.filtered(lambda x: (x.joint_buying_product_id))
for product in products:

vals = product._prepare_joint_buying_product("update")
global_product = product.joint_buying_product_id.with_context(
joint_buying=True, joint_buying_local_to_global=True
)
if (
product.company_id.joint_buying_partner_id
!= global_product.joint_buying_partner_id
):
raise AccessError(
_(
"You can not update the data of the product that belong to %s."
% global_product.joint_buying_partner_id.name
)
)
global_product.write(vals)

def _prepare_joint_buying_product(self, action):
Expand Down
Loading