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

[FIX] delivery_multii_desination: set dummy product #817

Closed
Closed
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 delivery_multi_destination/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"installable": True,
"depends": ["delivery"],
"demo": ["demo/delivery_carrier_demo.xml"],
"data": ["views/delivery_carrier_view.xml"],
"data": ["data/product_product.xml", "views/delivery_carrier_view.xml"],
}
14 changes: 14 additions & 0 deletions delivery_multi_destination/data/product_product.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>

<record model="product.product" id="dummy_shipping_product">
<field name="name">DUMMY Shipping Product</field>
<field name="type">service</field>
<field name="categ_id" ref="delivery.product_category_deliveries" />
<field name="sale_ok" eval="False" />
<field name="purchase_ok" eval="False" />
<field name="list_price">0.0</field>
<field name="invoice_policy">order</field>
</record>

</odoo>
4 changes: 3 additions & 1 deletion delivery_multi_destination/models/delivery_carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class DeliveryCarrier(models.Model):
def _onchange_destination_type(self):
"""Define the corresponding value to avoid creation error with UX."""
if self.destination_type == "multi" and self.child_ids and not self.product_id:
self.product_id = fields.first(self.child_ids.product_id)
self.product_id = fields.first(self.child_ids.product_id) or self.env.ref(
"delivery_multi_destination.dummy_shipping_product"
)

def search(self, args, offset=0, limit=None, order=None, count=False):
"""Don't show by default children carriers."""
Expand Down
Loading