summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-01-18 15:57:33 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-01-18 15:57:33 +0700
commitb33103dea998552d110d029d7f50ed08f58ce192 (patch)
tree190b234940e662bcaee85e4edfaf87481ce1184d
parent09c074be5de4fc10f6322303236b5919ff8234fb (diff)
add payment term validation in sales order and add website ads
-rw-r--r--indoteknik_api/controllers/api_v1/content.py20
-rwxr-xr-xindoteknik_custom/__manifest__.py1
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rwxr-xr-xindoteknik_custom/models/sale_order.py4
-rw-r--r--indoteknik_custom/models/website_ads.py18
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv3
-rw-r--r--indoteknik_custom/views/website_ads.xml69
7 files changed, 115 insertions, 1 deletions
diff --git a/indoteknik_api/controllers/api_v1/content.py b/indoteknik_api/controllers/api_v1/content.py
index 3d5b15e5..3d4e443a 100644
--- a/indoteknik_api/controllers/api_v1/content.py
+++ b/indoteknik_api/controllers/api_v1/content.py
@@ -6,6 +6,26 @@ from odoo.http import request
class WebsiteContent(controller.Controller):
prefix = '/api/v1/'
+ @http.route(prefix + 'product_ads', auth='public', methods=['GET', 'OPTIONS'])
+ def get_product_ads(self, **kw):
+ if not self.authenticate():
+ return self.response(code=401, description='Unauthorized')
+ base_url = request.env['ir.config_parameter'].get_param('web.base.url')
+ query = [
+ ('page', '=', 'product'),
+ ('status', '=', 'tayang')
+ ]
+ ads = request.env['website.ads'].search(query, order='sequence')
+ data = []
+ for ad in ads:
+ data.append({
+ 'id': ad.id,
+ 'name': ad.name,
+ 'image': base_url + 'api/image/website.ads/image/' + str(ad.id) if ad.image else '',
+ 'url': ad.url,
+ })
+ return self.response(data)
+
@http.route(prefix + 'video_content', auth='public', methods=['GET', 'OPTIONS'])
def get_video_content(self, **kw):
if not self.authenticate():
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index 908e74df..66184081 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -57,6 +57,7 @@
'views/website_content_channel.xml',
'views/website_content.xml',
'views/custom_mail_marketing.xml',
+ 'views/website_ads.xml',
'report/report.xml',
'report/report_banner_banner.xml',
'report/report_banner_banner2.xml',
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index 8ada3b95..5d5ad0ec 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -44,3 +44,4 @@ from . import x_biaya_kirim
from . import x_manufactures
from . import x_partner_purchase_order
from . import x_product_tags
+from . import website_ads
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index c8937ca4..5a4a653b 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -197,11 +197,15 @@ class SaleOrder(models.Model):
raise UserError("Payment Term pada Master Data Customer harus diisi")
if not order.partner_id.parent_id.active_limit:
raise UserError("Credit Limit pada Master Data Customer harus diisi")
+ if order.payment_term_id != order.partner_id.parent_id.property_payment_term_id:
+ raise UserError("Payment Term berbeda pada Master Data Customer")
else:
if not order.partner_id.property_payment_term_id:
raise UserError("Payment Term pada Master Data Customer harus diisi")
if not order.partner_id.active_limit:
raise UserError("Credit Limit pada Master Data Customer harus diisi")
+ if order.payment_term_id != order.partner_id.property_payment_term_id:
+ raise UserError("Payment Term berbeda pada Master Data Customer")
if not order.sales_tax_id:
raise UserError("Tax di Header harus diisi")
if not order.carrier_id:
diff --git a/indoteknik_custom/models/website_ads.py b/indoteknik_custom/models/website_ads.py
new file mode 100644
index 00000000..ec360294
--- /dev/null
+++ b/indoteknik_custom/models/website_ads.py
@@ -0,0 +1,18 @@
+from odoo import fields, models
+
+
+class WebsiteAds(models.Model):
+ _name = 'website.ads'
+
+ sequence = fields.Integer(string='Sequence')
+ name = fields.Char(string='Name')
+ image = fields.Binary(string='Image')
+ url = fields.Char(string='URL')
+ page = fields.Selection([
+ ('product', 'Product'),
+ ('homepage', 'Home Page')
+ ], string='Page')
+ status = fields.Selection([
+ ('tayang', 'Tayang'),
+ ('tidak_tayang', 'Tidak Tayang')
+ ], string='Status')
diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index 5eefa618..9349a566 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -25,4 +25,5 @@ access_customer_review,access.customer.review,model_customer_review,,1,1,1,1
access_website_content_channel,access.website.content.channel,model_website_content_channel,,1,1,1,1
access_website_content,access.website.content,model_website_content,,1,1,1,1
access_invoice_reklas,access.invoice.reklas,model_invoice_reklas,,1,1,1,1
-access_custom_mail_marketing,access.custom.mail.marketing,model_custom_mail_marketing,,1,1,1,1 \ No newline at end of file
+access_custom_mail_marketing,access.custom.mail.marketing,model_custom_mail_marketing,,1,1,1,1
+access_website_ads,access.website.ads,model_website_ads,,1,1,1,1 \ No newline at end of file
diff --git a/indoteknik_custom/views/website_ads.xml b/indoteknik_custom/views/website_ads.xml
new file mode 100644
index 00000000..b66b0346
--- /dev/null
+++ b/indoteknik_custom/views/website_ads.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<odoo>
+ <data>
+ <record id="view_website_ads_filter" model="ir.ui.view">
+ <field name="name">website.ads.list.select</field>
+ <field name="model">website.ads</field>
+ <field name="priority" eval="15"/>
+ <field name="arch" type="xml">
+ <search string="Search Content">
+ <field name="name"/>
+ <field name="url"/>
+ <field name="page"/>
+ <field name="status"/>
+ </search>
+ </field>
+ </record>
+
+ <record id="website_ads_action" model="ir.actions.act_window">
+ <field name="name">Website Ads</field>
+ <field name="res_model">website.ads</field>
+ <field name="search_view_id" ref="view_website_ads_filter"/>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <record id="website_ads_tree" model="ir.ui.view">
+ <field name="name">Website Ads</field>
+ <field name="model">website.ads</field>
+ <field name="arch" type="xml">
+ <tree>
+ <field name="sequence"/>
+ <field name="name"/>
+ <field name="image"/>
+ <field name="url"/>
+ <field name="page"/>
+ <field name="status"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="website_ads_form" model="ir.ui.view">
+ <field name="name">Website Ads</field>
+ <field name="model">website.ads</field>
+ <field name="arch" type="xml">
+ <form>
+ <sheet>
+ <group>
+ <group>
+ <field name="sequence"/>
+ <field name="name"/>
+ <field name="image"/>
+ <field name="url"/>
+ <field name="page"/>
+ <field name="status"/>
+ </group>
+ </group>
+ </sheet>
+ </form>
+ </field>
+ </record>
+
+ <menuitem
+ id="website_ads"
+ name="Website Ads"
+ parent="website_sale.menu_orders"
+ sequence="5"
+ action="website_ads_action"
+ />
+ </data>
+</odoo> \ No newline at end of file