Skip to content

new changes #832

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

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.languageServer": "None"
}
1 change: 1 addition & 0 deletions ecommerce/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions ecommerce/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
'name': 'E-commerce',
'version': '1.0',
'category': 'Website',
'summary': 'E-commerce module for managing products and categories',
'description': """
This module provides basic e-commerce functionalities including product management and category organization.
""",
'depends': "",
'data': [
'security/ir.model.access.csv',
'views/ecommerce_product_category_views.xml',
'views/ecommerce_product_views.xml',
'views/ecommerce_product_menus.xml',

],
'installable': True,
'application': True,

}
3 changes: 3 additions & 0 deletions ecommerce/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import ecommerce_product
from . import ecommerce_product_category
from . import ecommerce_product_offer
35 changes: 35 additions & 0 deletions ecommerce/models/ecommerce_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from odoo import fields, models,api


class EcommerceProduct(models.Model):
_name = 'ecommerce.product'
_description = 'E-commerce Product'

title = fields.Char('title', required=True, help="Title of the product")
description = fields.Text('Description', help="Description of the product")
price = fields.Float('Price', required=True, help="Price of the product", default=0.0)
quantity = fields.Integer('Quantity', required=True, help="Available quantity of the product", default=0)
category_id = fields.Many2one(
comodel_name='ecommerce.product.category',
string='Category',
help="Category of the product",
)
available = fields.Boolean(
string='Available',
compute='_compute_is_available',
store=True,
help="Indicates if the product is valid",
default=False,)






@api.depends('available', 'quantity')
def _compute_is_available(self):
for product in self:
if product.quantity > 0 :
product.available = True


15 changes: 15 additions & 0 deletions ecommerce/models/ecommerce_product_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from odoo import models, fields


class EcommerceProductCategory(models.Model):
_name = "ecommerce.product.category"
_description = "E-commerce Product Category"

name = fields.Char(string="Category Name", required=True)
description = fields.Text(string="Description")
product_id = fields.Many2one(
comodel_name="ecommerce.product",
string="Product Category",
ondelete="cascade",
)

31 changes: 31 additions & 0 deletions ecommerce/models/ecommerce_product_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from odoo import models, fields

class EcommerceProductOffer(models.Model):
_name = 'ecommerce.product.offer'
_description = 'Ecommerce Product Offer'

name = fields.Char(string='Offer Name', required=True)
product_id = fields.Many2one('ecommerce.product', string='Product', required=True)
discount_percentage = fields.Float(string='Discount Percentage', required=True, help="Discount percentage for the offer")
start_date = fields.Date(string='Start Date', required=True)
end_date = fields.Date(string='End Date', required=True)
status = fields.Boolean(string='Active', default=True, help="Indicates if the offer is currently active")


def action_accept_offer(self):
if 'accepted' in self.mapped('product_id.offer_ids.status'):
raise ValueError("There is already an accepted offer for this product.")
self.write({'status': 'accepted'})
return self.mapped('product_id').write({
'state': 'offer_accepted',
'selling_price': self.product_id.price * (1 - self.discount_percentage / 100),
})

def action_reject_offer(self):
self.write({'status': 'rejected'})
return self.mapped('product_id').write({
'state': 'offer_rejected',
})



3 changes: 3 additions & 0 deletions ecommerce/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_ecommerce_product_user,access.ecommerce.product.user,model_ecommerce_product,base.group_user,1,1,1,1
access_ecommerce_product_category_user,access.ecommerce.product.category.user,model_ecommerce_product_category,base.group_user,1,1,1,1
29 changes: 29 additions & 0 deletions ecommerce/views/ecommerce_product_category_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="ecommerce_product_category_action" model="ir.actions.act_window">
<field name="name">Products</field>
<field name="res_model">ecommerce.product.category</field>
<field name="view_mode">tree,kanban,form</field>
<field name="context">{'search_default_available': 1}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a product
</p>
<p>
Create products and manage their details.
</p>
</field>
</record>
<record id="ecommerce_product_tree" model="ir.ui.view">
<field name="name">Products</field>
<field name="model">ecommerce.product.category</field>
<field name="arch" type="xml">
<tree editable="bottom">
<field name="name"/>
<field name="description"/>
</tree>
</field>
</record>
</data>
</odoo>
6 changes: 6 additions & 0 deletions ecommerce/views/ecommerce_product_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<menuitem id="ecommerce_menu_root" name="E-commerce"/>
<menuitem id="ecommerce_product_menu" name="Products" parent="ecommerce_menu_root"/>
<menuitem id="ecommerce_product_menu_list" name="Product List" parent="ecommerce_product_menu" action="ecommerce_product_action"/>
</odoo>
34 changes: 34 additions & 0 deletions ecommerce/views/ecommerce_product_offer_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="ecommerce_product_action" model="ir.actions.act_window">
<field name="name">Products</field>
<field name="res_model">ecommerce.product.offer</field>
<field name="view_mode">tree,kanban,form</field>
<field name="context">{'search_default_available': 1}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a product offer
</p>
<p>
Create product offers and manage their details.
</p>
</field>
</record>
<record>
<field name="name">ecommerce.product.offer.tree</field>
<field name="model">ecommerce.product.offer</field>
<field name="arch" type="xml">
<tree decoration-success="status == 'accepted'" decoration-danger="status == 'refused'">
<field name="product_id"/>
<field name="partner_id"/>
<field name="price"/>
<field name="discount_percentage"/>
<button name="action_accept" type="object" title="Accept" icon="fa-check"/>
<button name="action_refuse" type="object" title="Refuse" icon="fa-times"/>
<field name="status" invisible='1'/>
</tree>
</field>
</record>
</data>
</odoo>
114 changes: 114 additions & 0 deletions ecommerce/views/ecommerce_product_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>

<record id="ecommerce_product_action" model="ir.actions.act_window">
<field name="name">Products</field>
<field name="res_model">ecommerce.product</field>
<field name="view_mode">tree,kanban,form</field>
<field name="context">{'search_default_available': 1}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a product
</p>
<p>
Create products and manage their details.
</p>
</field>
</record>


<record id="ecommerce_product_tree" model="ir.ui.view">
<field name="name">ecommerce.product.tree</field>
<field name="model">ecommerce.product</field>
<field name="arch" type="xml">
<tree decoration-success="available" decoration-danger="not available" decoration-muted="quantity == 0">
<field name="title"/>
<field name="category_id"/>
<field name="price"/>
<field name="quantity"/>
<field name="available" invisible="1"/>
</tree>
</field>
</record>

<record id="ecommerce_product_form" model="ir.ui.view">
<field name="name">ecommerce.product.form</field>
<field name="model">ecommerce.product</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<group>
<field name="title"/>
<field name="category_id"/>
<field name="price"/>
<field name="quantity"/>
<field name="available" invisible="1"/>
</group>
<notebook>
<page string="Description">
<field name="description" widget="text"/>
</page>
</notebook>
</group>
</sheet>
</form>
</field>
</record>
<record id="ecommerce_product_kanban" model="ir.ui.view">
<field name="name">ecommerce.product.kanban</field>
<field name="model">ecommerce.product</field>
<field name="arch" type="xml">
<kanban default_group_by="category_id" records_draggable="0">
<field name="available"/>
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_global_click">
<div>
<strong class="o_kanban_record_title">
<field name="title"/>
</strong>
</div>
<div>
Category: <field name="category_id"/>
</div>
<div>
Price: <field name="price"/>
</div>
<div>
Quantity: <field name="quantity"/>
</div>
<div t-if="record.available.raw_value">
<span class="badge badge-success">Available</span>
</div>
<div t-if="!record.available.raw_value">
<span class="badge badge-danger">Out of Stock</span>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>


<record id="ecommerce_product_search" model="ir.ui.view">
<field name="name">ecommerce.product.search</field>
<field name="model">ecommerce.product</field>
<field name="arch" type="xml">
<search>
<field name="title"/>
<field name="category_id"/>
<field name="price" filter_domain="[('price', '&lt;=', self)]"/>
<field name="quantity" filter_domain="[('quantity', '&gt;=', self)]"/>
<filter name="available" string="Available" domain="[('available', '=', True)]"/>
<filter name="out_of_stock" string="Out of Stock" domain="[('available', '=', False)]"/>
<group expand="0" string="Group By">
<filter name="group_by_category" string="Category" context="{'group_by': 'category_id'}"/>
</group>
</search>
</field>
</record>
</data>
</odoo>
1 change: 1 addition & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

{
'name': 'estate',
'version': '1.2',
'category': '',
'description': "",
'depends':"",
'application': True,
'data': [
'security/ir.model.access.csv',
'views/estate_property_type_views.xml',
'views/estate_property_tag_views.xml',
'views/estate_property_offer_views.xml',
'views/estate_property_views.xml',
'views/res_users_views.xml',
'views/estate_menus.xml'

]
}
5 changes: 5 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import estate_property
from . import estate_property_type
from . import estate_property_tag
from . import estate_property_offer
from . import res_users
Loading